Okay, I switched the way I was connecting, and started using a DSN
instead. However, I have been unable to use a DSN-Less connection
string for Mail Merge purposes, and I have been unable to
programatically create a SQL dsn that has UID and PWD information.
If I could either create a DSN-less connection string for Mail Merge,
or create a dsn during installation that contains all login
information, then I can call this project done.
Any ideas?
Thanks,
Chris McKenzie
Peter Jamieson wote:
> To be honest I'm amazed that your code would work with Word 2003 - if I use
> an OpenDataSource call that specifies a dsn file but no connection string,
[quoted text clipped - 78 lines]
> > Chris McKenzie
> > http://weblogs.asp.net/taganov
Peter Jamieson - 09 Oct 2006 17:32 GMT
With Word and ODBC you have to have a DSN.
If you use a machine (user/system) DSN (called "mydsn", say), you need
OpenDataSource _
Name:="", _
Connection:="DSN=mydsn;all your other connection info;", _
SQLStatement:="SELECT whatever"
and in Word 2002/2003 you will probably also need a further parameter,
Subtype:=wdMergeSubtypeWord2000
although in recent versions of 2003 you seem to be able to avoid that
If you use a file dsn (say, called c:\a\mydsn.dsn) then you need
OpenDataSource _
Name:="c:\a\mydsn.dsn", _
Connection:="FILEDSN=c:\a\mydsn.dsn;all your other connection info;", _
SQLStatement:="SELECT whatever"
(with the Subtype parameter as necessary.
In either case, you can include login and password information in "all your
other connection info". If you are using SQL Server integrated security, you
shouldn't need specific info., but you will need the correct text in the
connection string. I don't have the exact value names to hand but if you
can't find them, let me know.
It is certainly possible to put login/password in a file .dsn because a file
.dsn is just a text file in much the same format as .ini files, e.g.
[odbc]
keyword1=value1
keyword2=value2
etc.
However, as far as I know, if you include the login/password strings, they
are in clear text, not encrypted. It may be possible to include the same
things in a machine dsn by using the appropriate API or directly adding
entries to the registry, but I don't know for sure.
Not sure that answers your question, exactly, but if not let me know what
you're still missing...
Peter Jamieson
> Okay, I switched the way I was connecting, and started using a DSN
> instead. However, I have been unable to use a DSN-Less connection
[quoted text clipped - 103 lines]
>> > Chris McKenzie
>> > http://weblogs.asp.net/taganov