$ P $在VB.net ppared报表ODBC [英] Prepared Statements For ODBC in VB.net
问题描述
我的问题是pretty的简单的,但我根本无法看到我已经错了。
my question is a pretty simple one, however I simply cannot see where i have gone wrong.
我只是想知道如何创建一个在VB prepared声明。我知道在Java中,应当使用?而这些将被替换。我知道,在VB中使用@parametername。基本上我的code下来的地方,我用prepare方法和我得到的错误是,我的语法我插入不正确。对我来说,似乎该参数是没有得到取代在INSERT语句
I just want to know how to create a prepared statement in VB. I know in java one would use ? and these would get replaced. I am aware that in VB you use @ParameterName. Basically my code gets down to where i use the prepare method and the error i get is that my syntax for my insert is incorrect. To me it seems that the parameter is not getting substituted in the insert statement
例如。
Dim cmd As String = "insert into sites(id) values(@id)"
Dim odcmd As New OdbcCommand
odcmd.CommandText = cmd
odcmd.Parameters.Add("@id", OdbcType.Int)
odcmd.Parameters("@id").Value = 5
con.Open()
odcmd.Prepare()
odcmd.ExecuteNonQuery()
con.Close()
任何帮助吗?
Any help?
推荐答案
没关系,就解决了自己。
nevermind, solved it myself.
Dim cmd As String = "insert into sites(id) values(?)"
看来,它仍然使用了问号,相反的是我发现在网络上
Seems that it still uses the question marks, contrary to what i have found on the web
这篇关于$ P $在VB.net ppared报表ODBC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!