How to open two tables in single connection [one in currentdb, other in my new connection]

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Code:
[/FONT]
[FONT=Courier New]Dim conn As ADODB.Connection
conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\some folder\somefile.accdb;Persist Security Info=False;"[/FONT]
[FONT=Courier New]

Hi, using the above connection string, how can i open two tables and transfer data from on table to another

dim rst1 as dao.recordset
dim rst2 as adodb.recordset
etc....


Thanks in advance.
 
Why don't you just link the table?
That worked fine for me using the code I posted.


Norie, thanks alot. that worked for me too...:)
Once i was told here that linking and deleting the table again could take some time if the db is in Network/shared drive but that is a good learning...

And now the SQL thing also works perfect....thanks everyone. Thanks Xen, DK, Bob...everyone for always being there for me.

-------------------------------------------

Now one more question relating to this please.
When the sql command is used to transfer datas so i need to state cursor type, lock type etc?

Thanks again.



 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Now one more question relating to this please.
When the sql command is used to transfer datas so i need to state cursor type, lock type etc?

Thanks again.

Its a little complicated dealing with all these options. If you like, you can read up on it, but in my experience things work fine if you ignore these - just declare the recordset type and that's enough.
 
Upvote 0
Its a little complicated dealing with all these options. If you like, you can read up on it, but in my experience things work fine if you ignore these - just declare the recordset type and that's enough.


Xen ,thanks again. when we use sql line like this as we havent use anyline like rst.open etc, i thought maybe we dont have to specify the cursor type, adLockBatchOptimistic...adOpenStatic etc

Thanks again.
I really 'm liking this command:):):)

Code:
[/FONT]
[FONT=Courier New]sSQL = "INSERT INTO BUDGET ( MNG, BUDGET, QTR, YEARX ) IN '" & mydbname & "'" & vbNewLine & _
"SELECT BUDGET.MNG, BUDGET.BUDGET, BUDGET.QTR, BUDGET.YEARX" & vbNewLine & _
"FROM BUDGET;"[/FONT]
[FONT=Courier New][/FONT] 
[FONT=Courier New]conn.Execute sSQL[/FONT]
[FONT=Courier New][/FONT] 
[FONT=Courier New]
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top