I am having problems getting my VB.net application to insert values into my MySQL
. I can connect to the db, but cannot insert values. I have downloaded the DLL and have attached it as a reference. I have also taken the query written and plugged it directly into the db and it works. I have tried multiple ways of coding it from the examples I have found on this website, but I still cannot get it to work. This is the code I am trying to get to work:
Try
MysqlConn = New MySqlConnection("server=localhost;userid=User;password=******;database=Targets")
MysqlConn.Open()
Dim sqlCommand As New MySqlCommand
sqlCommand.CommandType = CommandType.Text
sqlCommand.CommandText = "insert into Victims(UserName, Machine, IP) values('" + strUser + "','" + strMachine + "','" + strIPAddress + "')"
Dim strRD As MySqlDataReader
strRD = sqlCommand.ExecuteReader()
MysqlConn.Close()
MessageBox.Show("connected")
Catch ex As MySqlException
MessageBox.Show("error")
I have declared the variables used in the query statement earlier in the code. Thanks for any help you could offer.