呢要先打开再赋值给com阿.
SqlConnection sql=new SqlConnection("Persist Security Info=False;uid=sa;pwd=sasa;database=sifang;server=ly;Connect Timeout=30"+
":");
com.Connection.Open();
SqlCommand com=new SqlCommand("select * from login where eno="+tbeditid.Text+"and code="+tbeditpw.Text,sql);
SqlConnection sql=new SqlConnection("Persist Security Info=False;uid=sa;pwd=sasa;database=sifang;server=ly;Connect Timeout=30"+
":");
com.Connection.Open();
SqlCommand com=new SqlCommand("select * from login where eno="+tbeditid.Text+"and code="+tbeditpw.Text,sql);
com.Connection.Open();
这个不能放在定义的前面,,,还是出现
用户 '(null)' 登录失败。原因: 未与信任 SQL Server 连接相关联。
sql.open();
,,就会这样,,,,,,,
Sql.OPen();
就是一打开联接就会这要的
高手多呀,,,真是的高手,,,快快现身呀
小弟,谢之,,,!!!!!!!!!!!!!!!!!!!!
":");sql.Open(); SqlCommand com=new SqlCommand("select * from login where eno="+tbeditid.Text+"and code="+tbeditpw.Text,sql);
com.ExecuteNonQuery();
不执行sqlConnection.Open();,,,用户名就不会空,,或者
sql server 不存在或,拒绝访问,,,可是不用写联接串,,,,,,先联好,,,就可以了,在用sqlCommand1.CommandType=CommandType.text;
在执行,,
sqlConnection1.Open();这样就可以了,,不知是什么回事有可能我说得不清楚,,,对不起呀,,,谢谢大家了!!!!!!!!!