Home > Software engineering >  Use Vb.NET 2010 try to write a simple login window, appear the following error
Use Vb.NET 2010 try to write a simple login window, appear the following error

Time:09-24

I really don't know what's going on, this problem bothering me four or five days, a great god, please help!
The code is as follows:
Imports System. The Configuration
Imports System. The Data. SqlClient

Public Class Login

Private Sub Button1_Click (sender As System. Object, e the As System. EventArgs) Handles for. Click
Dim nameStr As String=txtName. Text
Dim pwdStr As String=txtPwd. Text
If nameStr="" Then
MsgBox (" the user name cannot be empty!" )
TxtName. Focus ()
Return
End the If
If pwdStr="" Then
MsgBox (" password cannot be empty!" )
TxtPwd. Focus ()
Return
End the If
Dim connStr As String=ConfigurationManager. ConnectionStrings (" MyConnectionString "). The ConnectionString
Dim conn As SqlConnection=New SqlConnection (connStr)
Dim CMD As SqlCommand=New SqlCommand ()
Cmd.Com mandText="Select * from populated UserDetails where username='" & amp; NameStr & amp; "'
"Dim reader As SqlDataReader
Try
Conn. The Open ()
Reader=CMD. ExecuteReader ()
If reader. The Read () Then
If pwdStr=reader (" Pwd ") Then
MsgBox (" correct user and password ")
The Else
MsgBox (" wrong password ")
End the If
The Else
MsgBox (" not this user, please register again after landing ")
End the If
Catch the ex As Exception
Throw New ApplicationException (ex. ToString ())
The Finally
Reader. The Close ()
Conn. Close ()
End the Try
End Sub

Private Sub Button2_Click (sender As System. Object, e the As System. EventArgs) Handles Button2. Click
TxtName. Text=""
TxtPwd. Text=""
End Sub
The End of the Class


Also appear this problem:

I am a beginner, for this problem is very confused, a great god must help!

CodePudding user response:

CMD. Connection=conn, generally true,
  • Related