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,,