ms access 2007 - How to use 2 connection objects while importing data from one database to another in vb.net -
i using following code select 1 database , need insert database.. please suggest me code:
code :
'connection original database have import dim constrorg string = "provider=microsoft.ace.oledb.12.0;data source=" + strpath dim conn_orgdb new oledb.oledbconnection(constrorg) 'connection database have import dim app_path = system.appdomain.currentdomain.basedirectory() dim constr string = "provider=microsoft.ace.oledb.12.0;data source=" + app_path + "mydb.accdb" dim cnnoledb new oledb.oledbconnection(constr) dim strselinv_one string = ("select * inv_one (docu_dt>=@stdt , docu<=@enddt) ") dim comm_inv_one oledb.oledbcommand = new oledb.oledbcommand(strselinv_one, conn_orgdb ) comm_inv_one.parameters.addwithvalue("@stdt", sttime) comm_inv_one.parameters.addwithvalue("@enddt", endtime) dr = comm_inv_one.executereader while dr.read = true dim strinsinv1 string = "insert invoice_one(code_no,lay,..) select code_no,lay,... inv_one (code_no=@code)" dim comm_insinv1 oledb.oledbcommand = new oledb.oledbcommand(strinsinv1, cnnoledb) comm_insinv1.parameters.addwithvalue("@code", code_no) comm_insinv1.executenonquery() loop 'here invoice_one table belongs cnnoledb connection obj of 1 database , inv_one table belongs conn_orgdb connection object of database.. ' how use 2 connection object ? if use 1 connection object i.e. cnnoledb gives following error: " microsoft office access database engine cannot find input table or query 'inv_one'. make sure exists , name spelled correctly. "
please suggest me code.. thank you
try code, don't make long ( wack out stuff don't need , imput code, ....
in addition :
dim connectionstr = constants.input.mdb.connection_string & _ "data source=" & dbfullpath & ";" dim connection new system.data.oledb.oledbconnection(connectionstr)
in addition use
dim connectionstr2 = "other conection string" dim connection2 new system.data.oledb.oledbconnection(connectionstr)
and import code.
link: selecting data in ms access vb.net slow. doing right?
i sorry if won't help, since don't have access db cannot further test this. reguards.