Conection string

miwaypro

Active member
Joined
Oct 18, 2003
Messages
36
Location
Malaysia
Im no able to connect to the db
whats wrong with the following connection string?

myConnectionString = "server=GTT-PC-LIHUANG;Database=master;user id=sa;password=;"
 
Hi,
I would suggest this little nifty trick...
Make a new text file on your desktop.
Rename it to "WhatEverYouLike.udl"
Double click it and you will get a wizard helping you to connect to your database.
Once the connection is tested and functional open the udl-file in notepad and voil
 
>Make a new text file on your desktop.
>Rename it to "WhatEverYouLike.udl"
>Double click it and you will get a wizard helping you to connect to your database.

I tried that trick but when I double-clicked the desktop file, an error box popped up (labeled "Microsoft Data Link Error") with the following error message: "C:\Documents and Settings\User\Desktop\test.udl : File cannot be opened. Ensure it is a valid Data Link file."

Do I need to configure something to enable that trick to work for me? Im using WinXP Pro if that matters.
 
Look for a few examples of connection strings on the ConnectionStrings website.

Your connection string brings a question to mind, assuming SQL Server 2000.

What authentication mode is the server configured to use?

That question and link have the following notes regarding blank sa passwords:
Blank Password (not recommended)

If a user attempts to connect to an instance of SQL Server providing a blank login name, SQL Server uses Windows Authentication. Additionally, if a user attempts to connect to an instance of SQL Server configured for Windows Authentication Mode using a specific login, the login is ignored and Windows Authentication is used.
Im far from any kind of expert, but I interpret this to mean you cant login with a blank sa password, for all intents and purposes.
 
@Vagabond:
The docs say you cant provide a blank username, not blank password. Meaning, if you have this "server=myserver;database=mydatabase;uid=;pwd=;" then it will assume windows authentication.

The second part says that if your server is setup for Windows Authentication only (not mixed mode or SQL authentication), then it ignores a user name. So the string
"server=myserver;database=mydatabase;uid=nerseus;pwd=password;"
is the same as
"server=myserver;database=mydatabase;"

Ive always added "Trusted_Connection=Yes" or "Trusted_Connection=No" to my SQL Server connection strings.

@miwaypro:
Is "GTT-PC-LIHUANG" really the server name?

Similar to kejpas suggestion, assuming you have Visual Studio, open the Server Explorer and make a new connection. After you enter whatever you want to make the connection (make sure Test Connection works), you can grab the connection string from the wizard. Ive found it generally has a LOT of extra meta-data in it, but works fine for testing.

For SQL Server, Ive only used 5 parameters:
"server=myserver;database=mydatabase;uid=name;pwd=password;Trusted_Connection=No"
or these 3
"server=myserver;database=mydatabase;Trusted_Connection=Yes"

-ner
 
Please start a new thread, if you want people to reply. Its generally good practice to use a separate thread for separate questions.

Before you post the same one line question, please provide a little detail about what youve already tried, if anything. If you havent done any binding yet, let us know so we can point you to the right learning resources. There are lots of good samples on these forums and other websites.

-ner
 
Nerseus said:
Please start a new thread, if you want people to reply. Its generally good practice to use a separate thread for separate questions.

Before you post the same one line question, please provide a little detail about what youve already tried, if anything. If you havent done any binding yet, let us know so we can point you to the right learning resources. There are lots of good samples on these forums and other websites.

-ner

Thks for ur advise, i got an example from the MSDN web site, but is too complicated, i just want the easiest way of doing that.
 
Back
Top