S
sajecw
I created a mail merge letter using an ODC Data Source to a particula
table in my SQL database.
The fields that I want to allow my users to select from are in thi
table.
This table holds a copy of all of the information needed to print an
letter in my application. I also hold the letter document name to kno
which document to merge with. Each night, all printed letters ar
deleted from this table.
How do I use the MailMerge.OpenDataSource() method to use this ODC? I
it in the oConnection object?
I just realized I can send the SQLStatement with something like this
SELECT * FROM workletters WHERE gworktranid = '12345...'
This should print only the letter I need.
Can this be done with a dynamic connection string that I can create a
runtime?
I thought something like this should work...
object oLinkTo ="SQLOLEDB.1;Persist Security Info=True;Use
ID=sa;Password=x123;Data Source=fieldforcelap;Packet Size=4096;Initia
Catalog=collect1";
object oSqlStatement = "SELECT * FROM workletters where gworktranid
'1'";
wrdDoc.MailMerge.OpenDataSource("", ref oMissing, ref oMissing, re
oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oLinkTo, re
oSqlStatement, ref oMissing, ref oMissing, ref oMissing);
oDataDoc = wrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing
ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,re
oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,re
oMissing,ref oMissing);
It gives me a command failed error.
table in my SQL database.
The fields that I want to allow my users to select from are in thi
table.
This table holds a copy of all of the information needed to print an
letter in my application. I also hold the letter document name to kno
which document to merge with. Each night, all printed letters ar
deleted from this table.
How do I use the MailMerge.OpenDataSource() method to use this ODC? I
it in the oConnection object?
I just realized I can send the SQLStatement with something like this
SELECT * FROM workletters WHERE gworktranid = '12345...'
This should print only the letter I need.
Can this be done with a dynamic connection string that I can create a
runtime?
I thought something like this should work...
object oLinkTo ="SQLOLEDB.1;Persist Security Info=True;Use
ID=sa;Password=x123;Data Source=fieldforcelap;Packet Size=4096;Initia
Catalog=collect1";
object oSqlStatement = "SELECT * FROM workletters where gworktranid
'1'";
wrdDoc.MailMerge.OpenDataSource("", ref oMissing, ref oMissing, re
oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oLinkTo, re
oSqlStatement, ref oMissing, ref oMissing, ref oMissing);
oDataDoc = wrdApp.Documents.Open(ref oName, ref oMissing, ref oMissing
ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,re
oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,re
oMissing,ref oMissing);
It gives me a command failed error.