ASP中ADO连接SQLserver2000数据库语句?
答案:2 悬赏:0 手机版
解决时间 2021-12-16 22:13
- 提问者网友:做你怀里的猫
- 2021-12-16 05:59
ASP中ADO连接SQLserver2000数据库语句?
最佳答案
- 五星知识达人网友:魔法商店永不打烊
- 2021-12-16 06:21
05 //建立数据库连接字符串
06 string connectionstring = "server=localhost;database=northwind;
07 integrated security=sspi";
08 //将连接字符串传入sqlconnection对象的构造函数中
09 sqlconnection mysqlconnection = new sqlconnection(connectionstring);
10 try
11 {
12 //打开连接
13 mysqlconnection.open();
29 }
catch (exception err)
{
lblinfo.text = "读取数据库出错";
lblinfo.text += err.message;
}
finally
{
//关闭与数据库的连接
mysqlconnection.close();
lblinfo.text += "<br><b>关闭连接后的mysqlconnection对象的状态为:</b>";
lblinfo.text += mysqlconnection.state.tostring();
}
}
}
06 string connectionstring = "server=localhost;database=northwind;
07 integrated security=sspi";
08 //将连接字符串传入sqlconnection对象的构造函数中
09 sqlconnection mysqlconnection = new sqlconnection(connectionstring);
10 try
11 {
12 //打开连接
13 mysqlconnection.open();
29 }
catch (exception err)
{
lblinfo.text = "读取数据库出错";
lblinfo.text += err.message;
}
finally
{
//关闭与数据库的连接
mysqlconnection.close();
lblinfo.text += "<br><b>关闭连接后的mysqlconnection对象的状态为:</b>";
lblinfo.text += mysqlconnection.state.tostring();
}
}
}
全部回答
- 1楼网友:造墨迹
- 2021-12-16 06:51
改了下顺序和""
试试吧 好久不玩了
_bstr_t strconnect="provider=sqloledb;server=fzg"";database=test;uid=sa;pwd=
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯