Operator '+' is not defined for type 'Strings' and '1-dimensional array of Byte.' ALong with the following when i change the value back to PasswordTextBox
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''userlist' (UserName, Password, Email) Value ('test','test','test@test.com','Use' at line 1
Here is my code
Imports MySql.Data.MySqlClient
Imports System.Data
Imports System.Security.Cryptography
Imports System.Text
Public Class registration
Const AppName = "Gameapp MySQL Login System"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If UsernameTextBox.Text = "" Or PasswordTextBox.Text = "" Then
MessageBox.Show("Please enter the required information to login.", AppName, MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim mMySQLConnectionString As String = (My.Settings.myServer & My.Settings.myDB & My.Settings.myUsername & My.Settings.myPassword)
' You will need to change the connection string above to yours
Debug.WriteLine(mMySQLConnectionString)
Dim conn As MySqlConnection
Dim cmd As New MySqlCommand
conn = New MySqlConnection()
conn.ConnectionString = mMySQLConnectionString
Dim strText As String = PasswordTextBox.Text
Dim bytHashedData As Byte()
Dim encoder As New UTF8Encoding()
Dim md5Hasher As New MD5CryptoServiceProvider
bytHashedData = md5Hasher.ComputeHash(encoder.GetBytes(strText))
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error Connecting to Database")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim Sqlquery = "Select UserName From userlist WHERE UserName = '" + UsernameTextBox.Text + "'"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = Sqlquery
'Start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
'check to see if user exsits
If myData.HasRows = 0 Then
MsgBox("You are now Registerd.")
conn.Close()
conn.Open()
Dim registerfinal As New MySqlDataAdapter
Dim query = "INSERT INTO userlist (UserName, Password, Email) Value ('" + UsernameTextBox.Text + "','" + bytHashedData + "','" + EmailTextBox.Text + "','" + Label1.Text + "')"
Dim Command As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = query
'start query
myAdapter.SelectCommand = myCommand
myData = myCommand.ExecuteReader()
Else
MsgBox("Username already in use.")
End If
End If
End Sub
This post has been edited by crzyone9584: 09 April 2009 - 03:20 PM

New Topic/Question
Reply



MultiQuote






|