ADO _ConnectionPtr parameters
I'm trying to connect to my SQL server from a c++ console app. and this line of code drives me insane:
pConnection->Open("Server=PETERPAN\SQLEXPRESS;Database=WAW开发者_运维技巧I;User ID=Test; Password=Test;Trusted_Connection=False;","Test","Test",-1);
According to VS I'm supposed to provide the follwing information : (connectionstring,userID,pwd,longoption); The connection string I can find at eg http://www.connectionstrings.com/sql-server-2008 and it should be possible to find the right one...but:
If I for example use the string above and provide both username and pwd in the string, do I still have to provide it as the second and third parameter or can i leave them empty? And where can I find information about the last parameter "longoption"? What is it?
Thank you for your help,
Lumpi
Yes, you can pass empty strings as the 2nd and 3rd parameters if you provide this information in the connection string.
pConnection->Open("Server=PETERPAN\SQLEXPRESS;Database=WAWI;User ID=Test; Password=Test;Trusted_Connection=False;","","",-1);
Here is a how to tutorial on ado with c++.
Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=YourDBName;Persist Security Info=False;Data Source=.
is OK too.
精彩评论