呵呵,编程要严谨的,如果没有符合条件的行,dt.DataRows(0)肯定要出错的。
这样改一下代码:
Dim dr As DataRow
Dim dt As DataTable
Dim UserName As String=Forms("登录窗口").Controls("txtname").Value
Dim cmd As New SQLCommand
cmd.C
If UserName =" " Then
Messagebox.show("请输入用户名!","提 示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
cmd.CommandText = "Select * From {医师资料} Where [用户名] = '" & UserName & "' "
output.show(cmd.commandtext)
dt = cmd.ExecuteReader
If dt.DataRows.count > 0 Then
dr = dt.DataRows(0)
If Forms("登录窗口").Controls("txtpwd").Value = dr("密码") Then
DataTables("FMFM量表分值转换表").load
DataTables("精细运动能力测试量表").load
DataTables("脑瘫").load
Forms("登录窗口").Close
Else
Messagebox.show("密码错误!","提 示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
Else
messagebox.show("用户名错误","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If