postgresql - Specifying psqlODBC parameters in VB.NET -


just began using postgresql vb application (using visual studio 2005 pro) , connect via odbc (there's reason using odbc connection , not native postgresql connector) .

i'm used using @something , cmd.parameters.add("@something", data) format mssql. have 9 values want form , use them in insert statement can't seem figure syntax postgresql out.

ideas? i've searched 2 days trying find answer btw.

edit: sorry, deleted code trying, kept getting "the column not exist" error on column "name" first paramater.

i know it's not connection error or naming convention issue or because following code work. here's how i'm doing testing:

strsql = "insert tableb (name, extension, length,creationtime,lastaccesstime,lastwritetime,directoryname) values ('name','extension','length','creationtime','lastaccesstime','lastwritetime','directoryname')"  objconn.connectionstring = strconnstring         objconn.open()         objcmd              .connection = objconn             .commandtext = strsql             .commandtype = commandtype.text             .executenonquery()         end 

oh, , odbc version i'm using 8.03.02.00

more info: code causing error:

strsql = "insert tableb (name) values (@name)"      objconn.connectionstring = strconnstring     objconn.open()     'try     objcmd         .parameters.add("@name", sqldbtype.int)         .parameters("@name").value = "sometext"          .connection = objconn         .commandtext = strsql         .commandtype = commandtype.text         .executenonquery()     end 

code parameters:

the exact error: odbc exception:

"error [42703] error: column "name" not exist; error while executing query" 

the error occurs on .executenonquery

thanks again!

problem below code

.parameters.add("@name", sqldbtype.int) .parameters("@name").value = "sometext" 

you set name sqldbtype.int set text value

give correct column type when declare parameters , assign correct value match given data type.

and give parameters ? in sql statement , add command parameters in same sequence given in sql. odbc not support named parameters.

sample code :

strsql = "insert tableb (name) values (?)" objconn.connectionstring = strconnstring objconn.open() objcmd     .parameters.addwithvalue("name", "sometext")     .connection = objconn     .commandtext = strsql     .commandtype = commandtype.text     .executenonquery() end 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -