MailMerge OpenDataSource SSPI direct SQL Server connection

T

Thomas

Hello,
my problem is, that I can't get my OpenDataSource code working well.
Word opens another dialog where to choose a DataSource manual. Anyone
an idea what I do wrong? I need SSPI connection...

string table = "Userlist";
object cString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=True;Initial Catalog=KUMAgroup_MSCRM;Data
Source=KGRMACRM1;Use Procedure for Prepare=1;Auto Translate=1;Packet
Size=4096";
object sqlString = "SELECT * FROM [" + table + "]";

doc.MailMerge.OpenDataSource("", ref oMissing, ref oMissing, ref oTrue,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,ref oMissing, ref oMissing, ref cString, ref sqlString, ref
oMissing, ref oFalse, ref oMissing);
 
P

Peter Jamieson

To open a SQL Server connection using OLEDB, you have to have a .udl or .odc
file, even when you have provided all the necessary connection details in
cString. However, the .odc file (which is just a text file) can be an empty
file created in Notepad.

Peter Jamieson
 
T

Thomas

Hello Peter,
To open a SQL Server connection using OLEDB, you have to have a .udl or .odc
file, even when you have provided all the necessary connection details in
cString. However, the .odc file (which is just a text file) can be an empty
file created in Notepad.

Thx, now it work, but the connection needs much time to connect the
server. The manual way it's fast but with the programmatic
ConnectionString it's slow. Any idea?
 
P

Peter Jamieson

The manual way it's fast but with the programmatic
ConnectionString it's slow. Any idea?

Sorry, I don't know what could be causing that. The connection strings I use
here have similar settings to yours, and performance is OK. Leaving things
out such as the Merge subtype the parameter after "SQLStatement2" does not
seem to make much difference. But I am working in quite a benign environment
here.

You aren't using SQL Server 2005 are you? If so, you should probably try
using the new client OLEDB provider SQLNCLI.1. However, I don't see why it
would make a significant difference to performance.

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top