Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need you brandonio
#1
hey guys i just watch the 2nd tutorial on youtube about the implementation of MySQL to Visual Basic and it seems that i am having problem with the

data.Read()
and
data2 = command2.ExecuteReader

the error point out the two
when i try to test if the duplication of the username
also if i try to insert a new data


btw this is my code

[code2=vbnet]Private Sub cmdReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReg.Click
conn = New MySqlConnection("host=localhost; uid=root; pwd=root; database=mydatabase")

Dim Username As Boolean = True
conn.Open()
Dim mystr As String = "SELECT * FROM tbluser WHERE Username = '" & txtUser.Text & "';"
Dim mydr As MySqlDataReader
Dim myda As New MySqlDataAdapter
Dim mycmd As New MySqlCommand
mycmd.CommandText = mystr
mycmd.Connection = conn
myda.SelectCommand = mycmd
mydr = mycmd.ExecuteReader
While mydr.Read
If mydr.HasRows = True Then
MsgBox("Username Already exsist! Please choose another username.")
Username = False
mydr.Close()
Else
mydr.Close()
Username = True
End If
End While
mydr.Close()
If Username = True Then
Dim mystr2 As String = "INSERT INTO tbluser (FirstName, LastName, Contact#, Username, Password)VALUES ('" & txtUF.Text & "','" & txtUL.Text & "','" & txtUC.Text & "','" & txtUser.Text & "','" & txtPass.Text & "')"
Dim mydr2 As MySqlDataReader
Dim myda2 As New MySqlDataAdapter
Dim mycmd2 As New MySqlCommand
mycmd2.CommandText = mystr2
mycmd2.Connection = conn
myda2.SelectCommand = mycmd2
mydr2 = mycmd2.ExecuteReader
MsgBox("You've Registered!")
End If
End Sub
End Class[/code2]


i dont know how to write a proper topic on forums so sorry for if i made a mistake posting topics and please brandonio(awesome name but anyway)
i need your help, man.


Messages In This Thread
I need you brandonio - by kenomote - 10-12-2012, 09:41 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)