Showing posts with label team. Show all posts
Showing posts with label team. Show all posts

Friday, February 24, 2012

Connection String for SQL Server not working

I have the Visual Studio 2005 Team Suite trial version and the SQL Server 2005 trial (which came with team suite) installed in my machine.

When I installed the SQL Server 2005 I installed it in the Windows Authentication mode. So every time I open SQL Server 2005 it doesnt ask for Username/Password (Its greyed out). The only thing available were:

Server Type: Database Engine

ServerName: ServerSue

Authentication: Windows Authentication.

Here is my Problem:

I created a small application in C#. In the web.config file I created the following:

<

appSettings>

<

addkey="resumecon"value="SERVER=ServerSue;database=Resume;"/>

</

appSettings>

Then in the Code behind I created the following string:

string

strResCon =ConfigurationManager.AppSettings["resumecon"].ToString();

Then in method (for a Login page) I created the connection string as follows and wrote code to insert some values into the Resume database. I called this method on a button click event.

SqlConnection

conLogin =newSqlConnection(strResCon);

When I run the page and when I click the button I get the following error:

Login failed for user ''. The user is not associated with a trusted SQL Server connection.

I think some thing is wrong in the addkey of webconfig? How do I change this?

You have set the database for Windows Authentication but the user account accessing the database does not have permission to it. You need to know thw account used to access the database, which would be the ASP.NET Process account unless you're authenticating or impersonating. Grant that account access to the database or place it in a Windows group that has access.

Or use SQL Authentication.

Jeff

|||

Thanks Jeff. I am too new to SQL Server 2005. I have been using asp.net for the last 5 months and used SQL Server 2000 before.

I didnt quite understand what you mentioned. So is it safe for me to uninstall SQL Server 2005 and install it back with server authentication with a username and password? In that way I can specify the usaname password in the string

Because in the past with SQL Server 2000, I had some virus attack in my machine.

|||

You can use SQL either way, you just need to provide the correct authentication for it. Take a look atwww.connectionstrings.com for options in connecting to SQL, and the documentation for using Windows Authentication. In many cases I would recommend reconfiguring and using SQL Authentication, especially for beginners since most examples assume it, but it's really your choice.

Jeff

|||Thanks so much Jeff. I still havent got the time to do it. I am going to do this weekend and if things go wrong, (rarely I would say), I might post a question here.|||

I am back again. I uninstalled SQL Server 2005 and tried to re install it. But got stuck. When I got the window which says Instance name, there were 2 radio buttons: default instance and named instance.

I clicked the default instance radio button. Is this correct?

In the next window, Service Account window again there are 2 radio buttons:

1. Use the built-in service account radio button. This has a drop down with Local System and Network Service.

2. Use a domain user account radio button which is asking for user name, password, and domain.

Which one should I choose? I chose the second one and gave a username and password. But didnt know what to give for Domain name. Also I got an alert window saying some thing about my user name password not correct or so.

Sunday, February 19, 2012

Connection String Error

Hi Team

I am new to WEB sites as I normal work with Win apps.

I am using Server 2003 with SQL server 2005 Delevoper.

The server is on my own network in the same room..

I have made a new Web Site in Visual Studio 2005 DotNet Framework 2.0. It runs fine on testing.

I can log in and move around just fine. BUT when I publish it to the server the following happens:

I Can find the web site in internet explore from my Domain name (www.rbsoft.com.au) or Static IP. I get the default page up ok.

Then when I click on login I will get the login page. So I fill it in and click Login.

Then I get the follwing Error message.

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)

The Connection string is as follows:

<connectionStrings>

<add name="ConnectionString" connectionString="Data Source=RBSOFT-SERVER\MSSQLSERVER;AttachDbFilename=\App_Date\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

</connectionStrings>

I seems to me that the web site can not find the ASPNETDB.MDF database.

I can see the database on the server with "SQL Server Management Studio Express"

I spent many hours trying to find out why it will not work.

Can any one help me - Please

Regards

Ron B

please check spelling of \App_Date\*.mdf
DatE or Data