Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm no able to connect to the db

what's wrong with the following connection string?

 

myConnectionString = "server=GTT-PC-LIHUANG;Database=master;user id=sa;password=;"

programing programer program
Posted

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á there's your connection string. Copy and paste into your module and make the necessary changes for database location and such...

 

HTH

/Kejpa

  • 2 weeks later...
Posted

>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? I'm using WinXP Pro if that matters.

Posted

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.

I'm far from any kind of expert, but I interpret this to mean you can't login with a blank 'sa' password, for all intents and purposes.

"Never ascribe to malice that which can adequately be explained by incompetence." -- Napolean Bonaparte
  • *Experts*
Posted

@Vagabond:

The docs say you can't 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;"

 

I've 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 kejpa's 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. I've found it generally has a LOT of extra meta-data in it, but works fine for testing.

 

For SQL Server, I've 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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

Please start a new thread, if you want people to reply. It's 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 you've already tried, if anything. If you haven't 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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
Please start a new thread, if you want people to reply. It's 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 you've already tried, if anything. If you haven't 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.

programing programer program

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...