使用参数时mysql语法出错

时间:2012-08-15 10:22:58

标签: mysql vb.net parameters

当我使用参数时,我不断被告知我的mysql语法中存在错误。

这是我的代码:

    Dim db As New Database

    Dim sql As String = "select firstname, password from users where email = :email"

    Dim args As New List(Of MySqlParameter)
    args.Add(New MySqlParameter(":email", txtEmail.Text))

    ' execDB(procedurename As String, proceduretype As String, parameters() as MySqlParameter, returntype As String, newconnection As Boolean)

    Dim dr As MySqlDataReader = db.execDB(sql, "Text", args.ToArray, "DataReader", False)

错误指出:email不是有效值。我不明白为什么它没有使用参数,因为我将它传递给execDB函数。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

使用?param syntax

Dim sql As String = "select firstname, password from users where email = ?email"