Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Connect Two Cells | Excel Worksheet Functions | |||
Can I connect Excel cells to cells in an embedded Word table? | Excel Discussion (Misc queries) | |||
how do I connect cells on two pages? | New Users to Excel | |||
How do I connect two cells? If one cell changes the other changes | Excel Discussion (Misc queries) | |||
How to connect characters together in different cells? | Excel Discussion (Misc queries) |