Home > Net >  VB.net database query result set is less than the data
VB.net database query result set is less than the data

Time:09-15

The code
Imports MySql. Data. MySqlClient
Public Class Form1
'the data connection object
Dim con As New MySqlConnection
Dim comm As New MySqlCommand
'login data
Dim the user As the String
Dim pas As String
REM login
Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click
'
extract the input conditionsUser=Username. Text
Pas=Password. Text
The Debug. Print (user + CRH (10) + pas)
'the query
Dim SQL As String="select * from the userinfo where userName='" & amp; The user & amp; "'
"The Debug. Print (SQL)
Comm=New MySqlCommand (SQL, con)
Dim da=New MySqlDataAdapter (SQL, con)
Dim dt=New DataSet ()
Da. The Fill (dt, "SQL")
MsgBox (dt) Tables (" SQL ") Rows. Count)
Con. The Close ()


End Sub
'cancel function
Private Sub Button2_Click (sender As Object, As EventArgs e) Handles Button2. Click
The Username. Text=""
Password. The Text=""
End Sub
Private Sub Form1_Load (sender As Object, As EventArgs e) Handles MyBase. Load
'the data connection
Con. The ConnectionString="Server=127.0.0.1; UserID=root; Password=12345; The Database="candy"
Con. The Open ()
'the data connection state judging
If con. State=ConnectionState. Open Then
The Debug. Print (" database connection success!" )
The Else
The Debug. Print (" database connection failed!" )
End the If
End Sub

The End of the Class

CodePudding user response:

Can print out the SQL executed directly in the data detected data, and see if the userName is what type CHAR? This will automatically more Spaces

CodePudding user response:

And your comm=New MySqlCommand (SQL, con) defines it is no use to,,

CodePudding user response:

The
big watermelon a WuYiJin reference 1 floor? Reply:
print out the SQL in data direct execution can find out data, to see what is the userName type CHAR? This will automatically more Spaces
yes, have been in mysql

CodePudding user response:

The
reference 3 floor qq_36617490 response:
Quote: big watermelon a WuYiJin reference 1 floor? Response:

Can print out the SQL executed directly in the data detected data, and see if the userName is what type CHAR? This will automatically more Spaces
yes, in mysql for the
with varchar

CodePudding user response:

The
big watermelon a WuYiJin reference 2 floor? Response:
and your comm=New MySqlCommand (SQL, con) defines it is no use to,,

I changed to
'the query
Dim SQL As String="select * from the userinfo where userName='" & amp; The user & amp; "'
"The Debug. Print (SQL)
Comm=New MySqlCommand (SQL, con)
Dim da=New MySqlDataAdapter (comm)
Dim dt=New DataSet ()
Da. The Fill (dt, "SQL")
MsgBox (dt) Tables (" SQL ") Rows. Count)
Con. The Close ()
But do not check or data

CodePudding user response:

 
Dim SQL As String="select count (1) from the userinfo where userName='" & amp; The user & amp; "'
"Comm=New MySqlCommand (SQL, con)
Dim the count As Integer=comm. ExecuteScalar ()

See if or 0 on this?

CodePudding user response:

The
big watermelon a WuYiJin reference 7 floor? Response:
 
Dim SQL As String="select count (1) from the userinfo where userName='" & amp; The user & amp; "'
"Comm=New MySqlCommand (SQL, con)
Dim the count As Integer=comm. ExecuteScalar ()

See if or 0 on this?
0

CodePudding user response:

refer to the eighth floor qq_36617490 response:
Quote: big watermelon a WuYiJin reference 7 floor? Response:

 
Dim SQL As String="select count (1) from the userinfo where userName='" & amp; The user & amp; "'
"Comm=New MySqlCommand (SQL, con)
Dim the count As Integer=comm. ExecuteScalar ()

See if or 0 on this?
or
0

Check your table userName change is not Chinese name, any estimate is Chinese problem
Find my in mysql. Ini file
Under the [mysql] add: default - character - set=utf8
Under the [client] add: default - character - set=utf8
Under the [mysqld] add: character - set - server=utf8
Configured to restart the service to try again

CodePudding user response:

The
big watermelon a WuYiJin references 9 floor? Response:
Quote: refer to the eighth floor qq_36617490 response:

The
Quote: big watermelon a WuYiJin reference 7 floor? Response:

 
Dim SQL As String="select count (1) from the userinfo where userName='" & amp; The user & amp; "'
"Comm=New MySqlCommand (SQL, con)
Dim the count As Integer=comm. ExecuteScalar ()

See if or 0 on this?
or
0

Check your table userName change is not Chinese name, any estimate is Chinese problem
Find my in mysql. Ini file
Under the [mysql] add: default - character - set=utf8
Under the [client] add: default - character - set=utf8
Under the [mysqld] add: character - set - server=utf8
Configured to restart the service try again

Not Chinese names can get records, thank you
  • Related