Inserting a variable into Mysql table

solaar

Member
Joined
Jun 1, 2006
Messages
8
Programming Experience
1-3
Hi

I want to put a variable 'customerID' in an SQL statement to INSERT INTO a MySql table but don't know the syntax, i have looked and looked on the net but i can't get it to happen and am starting to crack-up. The code i'm using below works fine if i enter a value in apostrophes i.e '1234' but not for the variable. Any suggestions?

Public Function requestDetails(ByVal customerID As Object) As String Implements Itest.requestDetails
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim latin As String
'Connector/Net 1.0 (.NET)

conn = New MySqlConnection
conn.ConnectionString = "Server=localhost;Database=requests;Uid=root;Pwd=;"

Try
conn.Open()
Console.WriteLine("Connection Opened Successfully")
MySql.Data.MySqlClient.MySqlHelper.ExecuteScalar(conn, "INSERT INTO requests (customer_ID) VALUES (&customerID)")


conn.Close()
Catch myerror As MySqlException
Console.WriteLine("Error Connecting to Database: " & myerror.Message)
Finally
conn.Dispose()
End Try
Console.WriteLine(customerID)

End Function
 
Back
Top