I have this code for find in mysql.
Try
MysqlConn.Close()
MysqlConn.Open()
Dim Query As String
Query = "select id from foto where path = '" & TextBox5.Text & "'"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
While READER.Read
Dim sName = READER.GetString("id")
TextBox6.Text = sName
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
But the bad what i want is like C:\my pic\myfile.jpg
(TextBox5.Text) and mysql dont found it. But if i try like C:\\my pic\\myfile.jpg
it's ok. How i do to had a \\
(double slash) in my query ?
Thanks for the help..........
Try the MySql.Data.MySqlClient.MySqlHelper.EscapeString() method.
Try
MysqlConn.Close()
MysqlConn.Open()
Dim Query As String
Query = "select id from foto where path = @PATH"
COMMAND = New MySqlCommand(Query, MysqlConn)
COMMAND.AddWithValue("@PATH",MySql.Data.MySqlClient.MySqlHelper.EscapeString(Textbox5.Text))
READER = COMMAND.ExecuteReader
While READER.Read
Dim sName = READER.GetString("id")
TextBox6.Text = sName
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try