gpt4 book ai didi

mysql - VB NET - 查询 Mysql - 在哪里\

转载 作者:行者123 更新时间:2023-11-29 06:03:19 26 4
gpt4 key购买 nike

我有这段在 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

但糟糕的是我想要的是 C:\my pic\myfile.jpg (TextBox5.Text) 而 mysql 没有找到它。但是,如果我像 C:\\my pic\\myfile.jpg 这样尝试,就可以了。我如何在查询中使用 \\(双斜杠)?

感谢帮助..........

最佳答案

试试 MySql.Data.MySqlClient.MySqlHelper.EscapeString() 方法。

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

关于mysql - VB NET - 查询 Mysql - 在哪里\,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43349224/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com