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 ");
                }
Else
                {
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 127.0.0.1

It can be seen from this that the address of the server should be written. Because the server is running locally and the address 127.0.0.1 is bound to iis, you can write both localhost and 127.0.0.1. 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 169.254.218.201, you can also connect it as follows:

Private static string connstring = "server = 169.254.218.201; 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: info-contact@alibabacloud.com 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.