I have a problem which i have simplified below.
I have a sql statement which is filled in by parameters i.e Prepared statement. Is it possible to get the final prepared statement and store it in a variable
here is what i am trying to do but its not working
Dim cmd As New MySqlCommand("UPDATE `users` SET `email` = ?email", con)
cmd.Prepare()
cmd.Parameters.AddWithValue("?name", "newEmail")
Now here i tried doing this
Dim finalQuary As String = cmd.CommandText.ToString
I did that hoping to get this in the variable:
"UPDATE `users` SET `email` = theEmailAddress"
but instead i got the original unprepared statement i.e
UPDATE `users` SET `email` = ?email
i hope you understand my problem. if I’m not clear please tell me
The replacement is done MySQL-side at execution time. You’re basically trying to get the code of a function with all of the parameters replaced by the values provided. Unless VB.NET is emulating the prepared statement (which I’m guessing it’s not), or MySQL has an API to return an interpolated string (which to my knowledge it does not), you can’t get an interpolated-string-version of the query.