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.