我用的sqlConnection,专门用于连接ms sqlserver的类,如下:
string str_scn="data source=tyserver1;initial catalog=ty_price_2002;persist security info=False;user id=sa;password=tyforty;workstation id=CYC;packet size=4096";
SqlConnection scn=new SqlConnection(str_scn);
SqlCommand scd=new SqlCommand("sql select语句",scn);
scn.open();
SqlDataReader sdr=scd.ExecuteReader();要执行insert 语句要设置SqlCommand的insertcommand属性为insert sql语句.
string str_scn="data source=tyserver1;initial catalog=ty_price_2002;persist security info=False;user id=sa;password=tyforty;workstation id=CYC;packet size=4096";
SqlConnection scn=new SqlConnection(str_scn);
SqlCommand scd=new SqlCommand("sql select语句",scn);
scn.open();
SqlDataReader sdr=scd.ExecuteReader();要执行insert 语句要设置SqlCommand的insertcommand属性为insert sql语句.
str_scn="server=localhost;uid=sa;pwd=tyforty;database=tyserverl"
你在数据库中试建立一个aspnet用户,让他拥有足够的权利。
你的数据库的联接用户名为sa,而你想用aspnet用户名登录,那必须在数据库中进行用户配置,并授权给他才行。
为什么要把DBCONN分开几段呢,根本没有变量,何不写成一个STR?
不过我把以下的代码
DBConn = New OleDb.OleDbConnection("Provider=sqloledb;" & "server=localhost;" & "User=sa;" & "Password=0")
换成
DBConn = New OleDb.OleDbConnection("Provider=sqloledb;server=localhost;User=sa;Password=0")后
就一切正常了,奇怪呀,Wolfyee(肥牛火锅) 的提议不错