最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
VS2005中连接SQL Server2000 连接字符串
时间:2010-07-09 编辑:简简单单 来源:一聚教程网
vs2005中连接sql server2000 连接字符串
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.executereader();//sqldatareader doesn't have a constructor
if (datareader.read() == true)
{
response.redirect("modellist.asp教程x");
}
else
{
response.redirect("logerr.aspx");
}
//}
//catch (system.exception exception)
//{
// response.redirect("syserr.aspx");
//}
conn.close();//}
//catch (system.exception excetion1)
//{
// response.redirect("opendatabaseerr.aspx");
//}
/*
vs2005中连接sql server2000 连接字符串2009-11-05 22:54private static string connstring = "server=(local);database=webdevelop;uid=sa;pwd=sa";
这里的(local)还可以是localhost或者127.0.0.1
从这里可以看出,应该写服务器的地址,由于是本地运行,而且在iis中绑定了127.0.0.1这个地址,所以写localhost和127.0.0.1都可以。另外,(local)是sql server 2000 中的服务器对象,所以也是可以的。如果在iis中将此网站设为默认网站,而且绑定地址169.254.218.201,则还可以这样连接:
private static string connstring = "server=169.254.218.201;database=webdevelop;uid=sa;pwd=sa";
如果是数据库教程在远程服务器上运行,则此处应该写远程服务器的ip地址。
另外,打开和读取数据库 中数据时,很容易抛出异常,所以不要经常捕捉,否则会出错
-
下一个: asp.net多文件上传代码(完整实例)
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10