asp.net.ph

OleDbConnection.DataSource Property

System.Data.OleDb Namespace   OleDbConnection Class


Returns the location and file name of the data source.

Syntax


Script [ string variable = ] OleDbConnection.DataSource

Property Value


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.

Remarks

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.

Example

The following example shows the simplest way to retrieve and display the DataSource property of the current connection.

"DataSource: " + myConn.DataSource;
  C# VB

 Show me 

See Also

OleDbConnection Members   ConnectionString   ConnectionTimeout   Database Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph