Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect Two Cells Freshman Excel Worksheet Functions 3 May 20th 08 05:42 PM
Can I connect Excel cells to cells in an embedded Word table? PBJ Excel Discussion (Misc queries) 0 August 8th 07 08:24 PM
how do I connect cells on two pages? marketing123 New Users to Excel 3 August 6th 07 06:31 PM
How do I connect two cells? If one cell changes the other changes arttrust Excel Discussion (Misc queries) 1 July 22nd 07 09:38 AM
How to connect characters together in different cells? Eric Excel Discussion (Misc queries) 2 September 29th 06 02:57 AM


All times are GMT +1. The time now is 06:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"