有关VB.NET和SQLSERVER的问题,急!

来源:百度知道 编辑:UC知道 时间:2024/06/28 02:32:47
Me.SqlSelectCommand1.CommandText = "select 密码 from 学生信息表 where 学号 ='" & usernum & "'"
Me.SqlConnection1.Open()
pw = Me.SqlSelectCommand1.ExecuteScalar
If password = pw Then
f1.hide()
f2.show()
Else
MsgBox("错误")
End If
这是我做的一个学生登陆系统的程序的核心部分,报错为Me.SqlConnection1.Open()这一行出现问题“未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中”这是为什么?

pw = Me.SqlSelectCommand1.ExecuteScalar
把这一名改为:
pw = Convert.toString(Me.SqlSelectCommand1.ExecuteScalar)
就行了。

请检查是否添加了命名空间,然后检查SqlConnection1是否书写正确最后把select 密码 from 学生信息表 where 学号 ='" & usernum & "'单独提出来在SQL中运行下看是否有错
如果报错是你说的那样应该就是这3个地方哪出问题了

SqlSelectcommand1.Connection = SqlConnection1
不是你少了这步,就是你的数据库连接有问题。