![]() |
How to connect to SQL db & update cells
Does someone have some sample code, or maybe point me to a resource? I have an excel spreadsheet, Column A has EmployeeID#'s, say 500 rows worth. I want to loop thru each EmployeeID in ColA and query a SQL Server database for LastName, FirstName, etc. to populate ColB, ColC, etc. Any help would be extremely appreciated. Thanks in advance, ChrisB |
How to connect to SQL db & update cells
My Guess is that your used ADODB or DAO - I've not used them to connect to a SQL Server database but have done so with Access Databases - the code below adds some records to an access db - I think you would need to change the provider - do you have a connection string for the SQL db
Sub DelFirstRec( Dim rst As ADODB.Recordse Set rst = New ADODB.Recordse rst.Open "table name or SQL statement", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\___\db1.mdb;", adOpenKeyset, adLockOptimisti With rs .AddNe ![1] = "1 ![2] = "2 .Updat .Clos End Wit End Sub |
All times are GMT +1. The time now is 01:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com