Click here to Skip to main content
15,902,492 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Please,I am trying to,learn how to use databases in my application. This particular line of a code I googled out is not clear to me. Can any one explain it to me?
The full code is at: http://www.kbcafe.com/articles/HowTo.ADO.CPlusPlus.pdf
What does each parameter/argument mean and why?


connection->open(L"Provider=sqloledb; Data Source=fifa;L"Initial Catalog=test; User Id=testsa; Password=testsa",L"",L"",ADODB::adConnectUnspecified);
Posted

See ConnectionString Property (ADO)[^], Connection String Syntax[^] and Open Method (ADO Connection)[^]. Use the documentation to help you construct your ConnectionString and then, if it does not work, ask a specific question.

Explanation of Connection object Open Method parameters in your example
Syntax:
ConnectionString
Optional. A String value that contains connection information. See the ConnectionString property for details on valid settings.

UserID
Optional. A String value that contains a user name to use when establishing the connection.

Password
Optional. A String value that contains a password to use when establishing the connection.

Options
Optional. A ConnectOptionEnum value that determines whether this method should return after (synchronously) or before (asynchronously) the connection is established.

Details of each parameter
First Parameter (ConnectionString)
* Provider - The interface between your program and the database engine. There are several options. SQLOLEDB is the ADO.NET provider for Microsoft SQL Server.
* Data Source - The database server name or IP Address
* Initial Catalog - The name of the database on the database server
* User Id - A username configured into the database server
* Password - A password configured into the database server

Second Parameter (User Id)
First empty string - User Id passed as parameter instead of in ConnectionString

Third Parameter (Password)
Second empty string - Password passed as parameter instead of in ConnectionString

Fourth Parameter (Options)
ADODB::adConnectUnspecified - Specifies that the connection should be a synchronous connection. See ConnectOptionEnum[^]

Note
If you use Integrated Security, you do not need to use User Id and Password in the ConnectionString or in the Open statement.
 
Share this answer
 
v2
I can't tell you what all of them mean, however I can inform you of a most of them:

Provider = the type of connection, be it SQL, SQLite, MYSQL, etc.
Initial Catalog = name of the database,
User ID = username
password = password

I can never quite remember what the Data Source is, but it may refer to the server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900