miwaypro Posted October 4, 2005 Posted October 4, 2005 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=;" Quote programing programer program
kejpa Posted October 4, 2005 Posted October 4, 2005 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 Quote
Troy_Dot_Net Posted October 12, 2005 Posted October 12, 2005 >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. Quote
VagabondSW Posted October 12, 2005 Posted October 12, 2005 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. Quote "Never ascribe to malice that which can adequately be explained by incompetence." -- Napolean Bonaparte
*Experts* Nerseus Posted October 12, 2005 *Experts* Posted October 12, 2005 @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 Quote "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
miwaypro Posted October 13, 2005 Author Posted October 13, 2005 thks everyone, i solved my problem aleady, can someone tell me how to bind my selected data into datagrid? Quote programing programer program
miwaypro Posted October 13, 2005 Author Posted October 13, 2005 Can someone tell me how to bind my selected data? Quote programing programer program
*Experts* Nerseus Posted October 13, 2005 *Experts* Posted October 13, 2005 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 Quote "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
miwaypro Posted October 14, 2005 Author Posted October 14, 2005 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. Quote programing programer program
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.