Imports System.Data.SqlClient
Public Class frload
Public User As String
Public password As String
Dim conn As New SqlConnection("Server=.;" & _
"Database=ViBook; " & _
"Integrated Security=SSPI ")
Dim comm As New SqlCommand
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
User = TextBox1.Text
password = TextBox2.Text
Dim str As String
str = "select * from 管理员信息 where 姓名='" & User & "' and 密码='" & password & "'"
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = str
da.SelectCommand = comm
Try
conn.Open()
da.Fill(ds)
If ds.Tables(0).Rows.Count <> 0 Then
Dim frm2 As New frmain
frm2.Show()
Me.Hide()
Else
MessageBox.Show("密码或用户名错误,请重新输入", "提示信息")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
Catch ex As Exception
MessageBox.Show("登陆失败", "提示信息")
End Try
End Sub
这是代码每次第一次登陆如果输入错误的话第2次再登陆就是输对了也进不去了
急死