真不知道怎么回事,这个问题困扰我四五天了,请大神来帮忙!
代码如下:
Imports System.Configuration
Imports System.Data.SqlClientPublic Class Login    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim nameStr As String = txtName.Text
        Dim pwdStr As String = txtPwd.Text
        If nameStr = "" Then
            MsgBox("用户名不能为空!")
            txtName.Focus()
            Return
        End If
        If pwdStr = "" Then
            MsgBox("密码不能为空!")
            txtPwd.Focus()
            Return
        End If
        Dim connStr As String = ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString
        Dim conn As SqlConnection = New SqlConnection(connStr)
        Dim cmd As SqlCommand = New SqlCommand()
        cmd.CommandText = "Select*from UserDetails where username = '" & nameStr & "'"
        Dim reader As SqlDataReader
        Try
            conn.Open()
            reader = cmd.ExecuteReader()
            If reader.Read() Then
                If pwdStr = reader("Pwd") Then
                    MsgBox("正确的用户和密码")
                Else
                    MsgBox("错误的密码")
                End If
            Else
                MsgBox("没有此用户,请注册后再登陆")
            End If
        Catch ex As Exception
            Throw New ApplicationException(ex.ToString())
        Finally
            reader.Close()
            conn.Close()
        End Try
    End Sub    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        txtName.Text = ""
        txtPwd.Text = ""
    End Sub
End Class
另外还出现这个问题:我是初学者,对于这样的问题很困惑,大神一定要帮忙啊!