' 您先试试吧,您那段程序看来有年头了
Private Sub _Command1_0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _Command1_0.Click
Dim strSQL As String
Dim cn As New SqlClient.SqlConnection
Dim rs As New DataSet
cn.ConnectionString = "Provider=COMPUTER;Data Source=NEW;Initial Catalog=northwind;User Id=sa;Password=;"
' 不知道这个"Provider=COMPUTER"对不对,您是从书上看来的吧
cn.Open()
' rs.CursorLocation = adUseClient ' 不知道这一句的用处
strSQL = "select 密码 from NEW where 登录名='" & 用户登录_Renamed.Text & "'"
' rs.Open(strSQL, cn, adOpenStatic, adLockReadOnly)
Dim da As New SqlClient.SqlDataAdapter(strSQL, cn)
Dim count As Int32 = da.Fill(rs)
If count = 0 Then
MsgBox("用户名不正确")
Else
If rs.Tables(0).Rows(0)(0).Value = Text1.Text Then
MsgBox("登录成功")
Else
MsgBox("密码错误")
End If
End If
End Sub
Dim cn As system.data.sqlclient.SqlConnection
dim constr as string
constr="workstation id=你的ip;packet size=4096;user id=sa;data source=你的ip;initial catalog=你的数据库名称;password=" "
cn = New SqlConnection(constr)
cn.Open()