我写个连接数据库的类库
Imports System.Data
Imports System.Data.SqlClient
Public Class SQLClass1
inherits System.Data.SqlClient.SQLDebugging
Public Shared Connstr As String = "server=localhost;database=YSXT;uid=sa;pwd="
在form中引用Imports ClassLibrary1.SQLClass1
在buttonok中验证登陆
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
Dim strsql As String = "select *from users where id='" & Textname.Text & " ' and password='" & TextPwd.Text & " ' "
Dim mycon As New SqlConnection(Connstr)
Dim mycom As New SqlCommand(strsql, mycon)
Dim myreader As SqlDataReader
Try
mycon.Open()
myreader = mycom.ExecuteReader
If myreader.Read Then
strLoginRole = myreader(0)
blnLoginsucc = True
mycon.Close()
Dim s As New Formzhu
s.ShowDialog()
Me.Close()
Else
MsgBox("密码错误,请重新输入!", MsgBoxStyle.Exclamation)
TextPwd.Focus()
End If
Catch ex As Exception
MsgBox("sssss")
End Try
End Sub
每次登陆都是出现SSSSS,这是怎么回事啊!!!
急!谢谢各位了!!!
[此贴子已经被作者于2006-12-10 20:51:58编辑过]