二种asp教程.net连接数据库教程代码
//方法一
string strconn2 = system.configuration.configurationmanager.connectionstrings["connectionstring"].connectionstring;
sqlconnection conn = new sqlconnection(strconn2);
if (conn.state!=connectionstate.open)
{
conn.open();
}
//方法二
string strconn = system.configuration.configurationmanager.apps教程ettings.get("connectionstring");
sqlconnection conn = new sqlconnection(strconn);
if (conn.state!=connectionstate.open)
{
conn.open();
}
//如何要保存数据的话就
string insertsql = "....要保存的数据哦,www.111cn.net";
sqlcommand insertcommand=new sqlcommand(insertsql,conn);
insertcommand.executenonquery();
时间: 2024-10-23 20:00:04