最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net如何连接数据库
时间:2022-06-25 03:16:50 编辑:袖梨 来源:一聚教程网
asp教程.net如何连接数据库教程
下面是一款利用asp.net教程 c来连接mssql数据库,并查询出指定的数据哦。
string connstr = system.web.configuration.webconfigurationmanager.connectionstrings["sqlconnstr"].connectionstring;//这里
sqlconnection conn = new sqlconnection(connstr);
sqlcommand cmd = new sqlcommand();
cmd.connection = conn;
cmd.commandtext = "select id,xingming,gh from users where gh>600";
try
{
conn.open();
sqldatareader dr = cmd.executereader();
this.gridview1.caption = "员工信息表";
this.gridview1.datasource = dr;
this.gridview1.databind();}
catch (sqlexception gh)
{
throw gh;}
finally
{
if (conn.state == connectionstate.open)
{
conn.close();
}
}}
相关文章
- 《我的门派》输出装备搭配攻略 输出怎么搭配装备? 04-27
- 战火与永恒礼包码大全 04-27
- 《辐射4》q键使用介绍 04-26
- 《辐射4》人物介绍 04-26
- 《下一站江湖2》风卷残云获得方法 04-26
- 《The Star Named EOS未晓星程》配置要求介绍 04-26