Public Class MainClass Shared Sub Main() 'Declare variables and objects Dim strConnectionString As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=Employee.mdb;" Dim objConnection As New OleDbConnection(strConnectionString) Dim strSQL As String = _ "SELECT FirstName, LastName FROM Employee" Dim objCommand As New OleDbCommand(strSQL, objConnection) Dim objDataAdapter As New OleDbDataAdapter(objCommand) Dim objDataTable As New Data.DataTable("Employee") Dim objDataRow As DataRow
Try 'Open the database connection objConnection.Open()
'Check the state of the connection and report appropriately If objConnection.State = ConnectionState.Open Then Console.WriteLine( "Database connection is open") Else Console.WriteLine("Database connection failed") End If
Catch OleDbExceptionErr As OleDbException 'Write the exception Console.WriteLine(OleDbExceptionErr.Message) Catch InvalidOperationExceptionErr As InvalidOperationException 'Write the exception Console.WriteLine(InvalidOperationExceptionErr.Message) End Try
'Close the database connection objConnection.Close()
Data ultima modifica: 13 novembre 2012
Contatti Fax: 06.233.215.239
E-mail:
Gli articoli, i commenti, le recensioni e i messaggi sono di proprietà dell'autore
dove non diversamente specificato. Il webmaster non si assume alcuna
responsabilità riguardante l'utilizzo improprio del materiale pubblicato.