views:

309

answers:

1

Hi guys, my question is a pretty simple one, however I simply cannot see where i have gone wrong.

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

Eg.

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?

A: 

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

moonblade