Access query from VB.NET - To insert data though they are NULL -
i need insert data db db. run query vb.net:
for example:
insert dbdestino.tabladest (campo1,campo2) select valor1,valor2 dborigen.tablaorigen
field "campo1" integer (in dbdestino)
but value "valor1" (in dborigen) null. if run previous query, returns error , not insert data.
how can insert data though "valor1" null?
i doubt problem due null values in valor1, unless campo1 field rejects nulls.
you need insert statement access' database engine accept. example, statement executed in access dbdestino.mdb open:
insert tabladest ( campo1, campo2 ) select valor1, valor2 tablaorigen in 'c:\access\dborigen.mdb';
i'm not proficient vb.net, think can open connection dbdestino.mdb, , execute same insert statement works in access.
imports system.data.oledb module module1 dim cn oledbconnection dim cmd oledbcommand dim icount integer dim strinsert string sub main() cn = new oledbconnection("provider=microsoft.jet.oledb.4.0;" & _ "data source=c:\access\dbdestino.mdb;") cn.open() strinsert = "insert tabladest ( campo1, campo2 ) " & _ "select valor1, valor2 " & _ "from tablaorigen in 'c:\access\dborigen.mdb';" cmd = new oledbcommand(strinsert, cn) icount = cmd.executenonquery debug.print(icount) cn.close() end sub end module
i tested on system, , values tablaorigen inserted tabladest, nulls included.
Comments
Post a Comment