主题:未处理的“System.Data.SqlClient.SqlException”类型的异常……
未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。 其他信息: 系统错误。
错误图片已经上传,看的直接。
如果看不到代码,看下面。
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim con As String = "data source=22D40806BFE6477;integrated security=sspi;database=student"
Dim sqlcon As New SqlClient.SqlConnection(con)
Dim cmd As String = " select 用户名 from 学生信息 where 用户密码 = " & txtPassword.Text
Dim da As New SqlDataAdapter(cmd, sqlcon)
Dim ds As New DataSet
sqlcon.Open()
da.Fill(ds, "aa")
If ds.Tables("aa").Rows.Count > 0 Then
If txtPassword.Text = ds.Tables("aa").Rows(0)("用户密码") And radio1.Checked Then
frmLogin.ActiveForm.Visible = False
Dim fr As New frmMain
fr.ShowDialog()
ElseIf txtPassword.Text = ds.Tables("aa").Rows(0)("用户密码") And radio2.Checked Then
frmLogin.ActiveForm.Visible = False
Dim fs As New mainstudent
fs.ShowDialog()
Else
MsgBox("出现错误,请正确填写!")
txtPassword.Focus()
End If
Else
MsgBox("不存在此用户")
txtUsername.Text = ""
txtPassword.Text = ""
End If
sqlcon.Close()
End Sub
错误出现在 da.Fill(ds, "aa")
希望有人能帮我解决这个问题
错误图片已经上传,看的直接。
如果看不到代码,看下面。
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim con As String = "data source=22D40806BFE6477;integrated security=sspi;database=student"
Dim sqlcon As New SqlClient.SqlConnection(con)
Dim cmd As String = " select 用户名 from 学生信息 where 用户密码 = " & txtPassword.Text
Dim da As New SqlDataAdapter(cmd, sqlcon)
Dim ds As New DataSet
sqlcon.Open()
da.Fill(ds, "aa")
If ds.Tables("aa").Rows.Count > 0 Then
If txtPassword.Text = ds.Tables("aa").Rows(0)("用户密码") And radio1.Checked Then
frmLogin.ActiveForm.Visible = False
Dim fr As New frmMain
fr.ShowDialog()
ElseIf txtPassword.Text = ds.Tables("aa").Rows(0)("用户密码") And radio2.Checked Then
frmLogin.ActiveForm.Visible = False
Dim fs As New mainstudent
fs.ShowDialog()
Else
MsgBox("出现错误,请正确填写!")
txtPassword.Focus()
End If
Else
MsgBox("不存在此用户")
txtUsername.Text = ""
txtPassword.Text = ""
End If
sqlcon.Close()
End Sub
错误出现在 da.Fill(ds, "aa")
希望有人能帮我解决这个问题