vb.net中主窗体一闪而过
Imports System.Data.SqlClientPublic Class Form1
Public blnloginsucc As Boolean
Public Shared connstr As String = "server =jm;database=mydb;uid=sa;pwd=sa"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strsql As String = "select * from users where id ='" & cmbid.Text & " 'and pwd= '" & txtpwd.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 = True Then
blnloginsucc = True
mycon.Close()
Me.Close()
frmmain.ShowDialog()
Else
MsgBox("密码错误,请重新输入!", MsgBoxStyle.Exclamation)
txtpwd.Focus()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
End Class
就是运行后,在登录窗口填上用户名和密码后,窗体消失,但主窗体出来闪一下,也消失拉,请高手指点