我使用第一个账号登录,进入主菜单后,点击返回登录,重新输入另一个账号信息,登录主菜单显示还是上一个账号的信息,求助,这是登录页面的代码
Imports System.Data.SqlClient
Public Class login
Dim Conn As SqlConnection
Public sf As String
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles regist.Click
register.Show()
End Sub
Private Sub log_Click(sender As System.Object, e As System.EventArgs) Handles log.Click
Dim name, pad As String
name = yname.Text
pad = ypad.Text
If ComboBox1.SelectedIndex = 0 Then
sf = "管理员"
ElseIf ComboBox1.SelectedIndex = 1 Then
sf = "挂号员"
Else
sf = "医生"
End If
If name = "" Then
MessageBox.Show("用户名不能为空")
ElseIf pad = "" Then
MessageBox.Show("密码不能为空")
Else
Conn = New SqlConnection()
Conn.ConnectionString = "Server=(local);database=mzgh;Integrated Security=True"
Conn.Open()
Dim Comm As New SqlCommand("select * from yhxx where y_name='" & name & "' and y_pad='" & pad & "'", Conn)
Dim ds As DataSet = New DataSet
Dim da As New SqlDataAdapter
da.SelectCommand = Comm
da.Fill(ds, "yhxx")
If ds.Tables("yhxx").Rows.Count = 0 Then
MsgBox("用户名或密码错误,请重新输入!")
Else
MsgBox("登录成功!")
Me.Hide()
Main.Show()
End If
Conn.Close()
End If
End Sub
Private Sub cancel_Click(sender As System.Object, e As System.EventArgs) Handles cancel.Click
yname.Text = ""
ypad.Text = ""
End Sub
Private Sub log_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles log.MouseDown
Dim n As String
n = yname.Text
Conn = New SqlConnection()
Conn.ConnectionString = "Server=(local);database=mzgh;Integrated Security=True"
Conn.Open()
Dim Comm As New SqlCommand("select y_name from yhxx where y_name='" & n & "'", Conn)
Dim ds As DataSet = New DataSet
Dim da As New SqlDataAdapter
da.SelectCommand = Comm
da.Fill(ds, "yhxx")
If ds.Tables("yhxx").Rows.Count = 0 Then
MsgBox("用户名不存在,请先注册!")
End If
Conn.Close()
End Sub
End Class
这是主菜单代码