Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mailmerge using Network Server | Mailmerge | |||
Error when directly printing mailmerge document | Mailmerge | |||
Mail Merge Directly From SQL Server | Mailmerge | |||
Connecting to SQL Server for mailmerge | Mailmerge | |||
directly connecting the MailMerge object to MS SQL server | Mailmerge |