Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ang Ang is offline
external usenet poster
 
Posts: 9
Default Mailmerge getting data in sql server directly

http://www.codeproject.com/KB/cs/C__..._Mailmerg.aspx

Dear all,

I found a sample code which we don't need to create a datasource file
for mailmerge, we can directly get the data from DSN. However, how can I
get the data directly from SQL server 2005? Can anyone show me the code
of this part? Many Thanks.
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Mailmerge getting data in sql server directly

Here is how to get information from a SQLEXPRESS database

Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Public constring As String

constring = "Provider=SQLOLEDB.1;" _
& "Server=GLOBAL-C66780E6\SQLEXPRESS;" _
& "Database=nameofdatabase;" _
& "Integrated Security=SSPI;" _
& "DataTypeCompatibility=80;"
con.ConnectionString = constring
con.Open
Set rst.ActiveConnection = con
With rst
.Source = "SELECT * FROM Applicants ORDER BY ApplicantName"
For i = 1 To .Fields.Count
lstAppFields.AddItem .Fields(i - 1).Name
Next i
lstApplicants.ColumnCount = .Fields.Count
.Open
i = .RecordCount
lstApplicants.Column = .GetRows(i)
End With
Set rst = Nothing


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Ang" wrote in message
...
http://www.codeproject.com/KB/cs/C__..._Mailmerg.aspx

Dear all,

I found a sample code which we don't need to create a datasource file
for mailmerge, we can directly get the data from DSN. However, how can I
get the data directly from SQL server 2005? Can anyone show me the code
of this part? Many Thanks.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailmerge using Network Server Bren Mailmerge 1 November 16th 07 01:40 AM
Error when directly printing mailmerge document Don Mailmerge 1 May 18th 06 11:18 PM
Mail Merge Directly From SQL Server Vaughn Haybittle Mailmerge 1 April 12th 06 08:07 AM
Connecting to SQL Server for mailmerge [email protected] Mailmerge 4 June 2nd 05 07:18 AM
directly connecting the MailMerge object to MS SQL server Gerhard Kiessling Mailmerge 1 May 25th 05 05:01 PM


All times are GMT +1. The time now is 08:50 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"