Connecting SQL Server2000 connection string in VS2005

Source: Internet
Author: User

Connecting SQL server2000 connection string in vs2005

Sqlconnection conn = new sqlconnection (sqlconn. connstring );
String sqltext = "select * from loginuser where (username = '" + name + "') and (" + "userpwd = '" + pwd + "')";
Sqlcommand command = new sqlcommand (sqltext, conn );
// Try
Conn. open ();
// Try to get the information and identification
// Try
Sqldatareader datareader = command.exe cutereader (); // sqldatareader doesn't have a constructor
If (datareader. read () = true)
Response. redirect ("modellist. asp tutorial x ");
Response. redirect ("logerr. aspx ");
// Catch (system. exception)
// Response. redirect ("syserr. aspx ");
Conn. close ();

// Catch (system. exception excetion1)
// Response. redirect ("opendatabaseerr. aspx ");

Connection string 2009-11-05 22: 54 private static string connstring = "server = (local); database = webdevelop; uid = sa; pwd = sa ";

Here (local) can also be localhost or

It can be seen from this that the address of the server should be written. Because the server is running locally and the address is bound to iis, you can write both localhost and In addition, (local) is a server object in SQL server 2000, so it is also possible. If you set this website as the default website in iis and bind the address, you can also connect it as follows:

Private static string connstring = "server =; database = webdevelop; uid = sa; pwd = sa ";

If the database tutorial runs on a remote server, the IP address of the remote server should be written here.

In addition, when opening and reading data in the database, it is easy to throw an exception, so do not capture it frequently; otherwise, an error will occur.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.