Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

help mysql vb.net

kemuel753

Apprentice
Advanced Member
Messages
51
Reaction score
0
Points
26
pa help mysql vb.net may table aq sa database na userID,Name,Password pag nag enter aq userID dapat lalabas din ung name sa txtName.text nya ,,e2 po ung code may error laging column not found



Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim con As New MySqlConnection("host=localhost; username=root; password=pass; database=login;")
Dim cmd As New MySqlCommand
Dim dr As MySqlDataReader
con.Open()
cmd.Connection = con
cmd.CommandText = "select UserID,Password from login_tb where UserID='" & txtUserID.Text & "'and Password='" & txtPassword.Text & "'"
dr = cmd.ExecuteReader
While dr.Read
frmTime_in.txtName.Text = dr.GetString("Name")
End While
If dr.HasRows Then
Me.Close()
frmTime_in.MdiParent = Main
frmTime_in.Show()
Else
MessageBox.Show("You have enetered an invalid password. Please try again.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtUserID.SelectAll()
txtPassword.Focus()
End If
con.Close()
End Sub
 
Tingin ko dito ang error:

cmd.CommandText = "select UserID,Password from login_tb where UserID='" & txtUserID.Text & "'and Password='" & txtPassword.Text & "'"

Try mo gawing ganto:
cmd.CommandText = "select UserID,Password from login_tb where UserID='" & txtUserID.Text & "' and Password='" & txtPassword.Text & "'"
 
pa help mysql vb.net may table aq sa database na userID,Name,Password pag nag enter aq userID dapat lalabas din ung name sa txtName.text nya ,,e2 po ung code may error laging column not found



Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim con As New MySqlConnection("host=localhost; username=root; password=pass; database=login;")
Dim cmd As New MySqlCommand
Dim dr As MySqlDataReader
con.Open()
cmd.Connection = con
cmd.CommandText = "select UserID,Password from login_tb where UserID='" & txtUserID.Text & "'and Password='" & txtPassword.Text & "'"
dr = cmd.ExecuteReader
While dr.Read
frmTime_in.txtName.Text = dr.GetString("Name")
End While
If dr.HasRows Then
Me.Close()
frmTime_in.MdiParent = Main
frmTime_in.Show()
Else
MessageBox.Show("You have enetered an invalid password. Please try again.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtUserID.SelectAll()
txtPassword.Focus()
End If
con.Close()
End Sub

cmd.CommandText = "select UserID,Password,`name` from login_tb where UserID=@userId and Password=@userPass"
cmd.Parameters.AddWithValue("@userId", txtUserID.Text)
cmd.Parameters.AddWithValue("@userPass", txtPassword.Text)

hindi mo kasi na specify ang column kaya di nya mahanap.
 
cmd.CommandText = "select UserID,Password,`name` from login_tb where UserID=@userId and Password=@userPass"
cmd.Parameters.AddWithValue("@userId", txtUserID.Text)
cmd.Parameters.AddWithValue("@userPass", txtPassword.Text)

hindi mo kasi na specify ang column kaya di nya mahanap.

Salamat po gumana na nxt time po ulit :salute::salute::salute:
 
Back
Top Bottom