Sql query from excel via VBA

masterx7

New Member
Joined
Nov 2, 2016
Messages
16
Hi,
I've connected excel to SQL server.
when the connection is made in Queries & Connections with SQL language (No VBA), the excel table refreshes OK and non relevant rows disappear from the table with every hit on Refresh all button.
the problem with this method is that everyone can see the user and password as part of the connection string.
so I switch to VBA, put a password on the project. and creating all queries from there.
now the problem is with the updating of the table.
when hit refresh all, new data is going into the table OK, but the non relevant rows stay.
for example, I have to prepare an order, once finished it should disappear from the table and it's not.
the workaround is to first delete the content of that table and then move on with pulling the recordset.

the question is, is there a way to update table without first removing it's content?
because when I'm using VBA, the user cant move the headers to it's liking.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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