System.Data.OleDb Namespace OleDbConnection Class
Returns the location and file name of the data source.
Script |
[ string variable = ] OleDbConnection.DataSource |
variable |
Returns the location and file name of the data source. |
The property is read only with no default value.
NOTE: You can change the value for this property only by setting the associated keyword in the ConnectionString property.
For the Jet Provider, if the data source does not reside in the same directory as the calling page, the complete path from the application root to the data source must be specified using the Server.MapPath property in the connection string. For example:
OleDbConnection myConn = new OleDbConnection (
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" +
Server.MapPath ( "~/app_data/dbtutor.mdb" ) );
NOTE: The connection string MUST NOT contain any spaces, either before or after the equal ( = ) signs within the string, and must be written as a single line without any line breaks. The code examples shown here are done so only for readability.
The following example shows the simplest way to retrieve and display the DataSource property of the current connection.
"DataSource: " + myConn.DataSource;
"DataSource: " + myConn.DataSource |
|
C# |
VB |
Show me
OleDbConnection Members ConnectionString ConnectionTimeout Database