Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mctaff
Starting Member
13 Posts |
Posted - 2009-12-22 : 07:31:05
|
Hi,I'm trying to connect to a SQL Server database from C++, using ODBC - SQLDriverConnectI've tried multiple connection strings, from a basicDSN:FTSto an involvedData Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\FTS.mdf\";Integrated Security=True;Connect Timeout=30;User Instance=Truewhich is the connection string Visual Studio uses if I configure a connection to the database via the Tools menu.I've also looked at the connection string by chaging SQLDriverConnect to use SQL_DRIVER_PROMPT. This then pops up a dialog, and I picked the approrpaite DSN from the list, and looked at the returned connection string variable, which had been used to sucessfully connect: DSN=FTS;Description=Financial Time Series;UID=Taff;Trusted_Connection=Yes;WSID=HAL;DATABASE=FTS;I've also tried a few other combinations, involving the Server, Trusted Connection and Database tags. Nothing works.The odbc.ini file is present and correct, with the FTS dsn as an entry. The dsn clearly exists given when I use the SQL_DRIVER_PROMPT parameter a dialog pops up which lets me select the dsn. The error I'm consistently getting is "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"It's all rather frustrating, for something that should be extremely simple! Can anyone help? |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-12-22 : 08:30:17
|
See if this helps:http://support.microsoft.com/default.aspx/kb/306345 |
 |
|
mctaff
Starting Member
13 Posts |
Posted - 2009-12-22 : 11:42:05
|
Thanks for the post Rick, but the permissions are already setup, and I'm hosting the database on my local machine...Any other ideas? |
 |
|
mctaff
Starting Member
13 Posts |
Posted - 2010-01-16 : 14:25:04
|
I figured out the issue...Compiler is using Unicode, meaning the connection strings etc needed to be converted to wchars, by wrapping in the TEXT() function.Or you can just turn the unicode compile option off, which is more straightforward.... |
 |
|
|
|
|
|
|