求助ExecuteReader 要求已打开且可用的 Connection.连接的当前状态为已关闭. 10
protectedvoidbtnSubmit_Click(objectsender,EventArgse){stringConnString="server=localh...
protected void btnSubmit_Click(object sender, EventArgs e)
{
string ConnString = "server=localhost;database=SampleDatabase;Trusted_Connection=SSPI";
SqlConnection Conn = new SqlConnection(ConnString);
string sql_username = "select * from Logon where UserName= '" + txtUserName.Text.Trim();
string sql_login="select * from Logon where UserName= '" + txtUserName.Text.Trim() + "'and Password= '" + txtPassword.Text.Trim();
Conn.Open();
SqlCommand SqlComm_username = new SqlCommand(sql_username,conn);
SqlCommand SqlComm_login = new SqlCommand(sql_login, conn);
SqlDataReader dr_username = SqlComm_username.ExecuteReader();//这句报错
SqlDataReader dr_login = SqlComm_login.ExecuteReader(); 展开
{
string ConnString = "server=localhost;database=SampleDatabase;Trusted_Connection=SSPI";
SqlConnection Conn = new SqlConnection(ConnString);
string sql_username = "select * from Logon where UserName= '" + txtUserName.Text.Trim();
string sql_login="select * from Logon where UserName= '" + txtUserName.Text.Trim() + "'and Password= '" + txtPassword.Text.Trim();
Conn.Open();
SqlCommand SqlComm_username = new SqlCommand(sql_username,conn);
SqlCommand SqlComm_login = new SqlCommand(sql_login, conn);
SqlDataReader dr_username = SqlComm_username.ExecuteReader();//这句报错
SqlDataReader dr_login = SqlComm_login.ExecuteReader(); 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏10(财富值+成长值)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询