S
SOlva
This is the code that I am running can anyone help me
understand why I get the following error
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
' IMport Data and Oledb namespaces
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim myConnection As OleDbConnection = New _
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
database = c:\concord.mdb")
Dim myDataAdapter As New OleDbDataAdapter()
Dim myDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
' Set the SelectCommand properties
myDataAdapter.SelectCommand = New OleDbCommand()
myDataAdapter.SelectCommand.Connection =
myConnection
myDataAdapter.SelectCommand.CommandText = _
"SELECT CustNum, WorkPhone, Alt Phone,
Firstname, LastName, Address, Address1, City,
StateOrProvince " & _
"FROM customer " & _
"ORDER BY LastName, LastName"
myDataAdapter.SelectCommand.CommandType =
CommandType.Text
' OPen the database connection
myConnection.Open()
'Now execute the command
myDataAdapter.SelectCommand.ExecuteNonQuery()
' Fill DataSet object with data
myDataAdapter.Fill(myDataSet, "customers")
'Close the database connection
myConnection.Close()
' Set the dataGrid properties to bind it to our
data
grdCustomerInfo.DataSource = myDataSet
grdCustomerInfo.DataMember = "customers"
End Sub
End Class
understand why I get the following error
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
' IMport Data and Oledb namespaces
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
Dim myConnection As OleDbConnection = New _
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
database = c:\concord.mdb")
Dim myDataAdapter As New OleDbDataAdapter()
Dim myDataSet As DataSet = New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
' Set the SelectCommand properties
myDataAdapter.SelectCommand = New OleDbCommand()
myDataAdapter.SelectCommand.Connection =
myConnection
myDataAdapter.SelectCommand.CommandText = _
"SELECT CustNum, WorkPhone, Alt Phone,
Firstname, LastName, Address, Address1, City,
StateOrProvince " & _
"FROM customer " & _
"ORDER BY LastName, LastName"
myDataAdapter.SelectCommand.CommandType =
CommandType.Text
' OPen the database connection
myConnection.Open()
'Now execute the command
myDataAdapter.SelectCommand.ExecuteNonQuery()
' Fill DataSet object with data
myDataAdapter.Fill(myDataSet, "customers")
'Close the database connection
myConnection.Close()
' Set the dataGrid properties to bind it to our
data
grdCustomerInfo.DataSource = myDataSet
grdCustomerInfo.DataMember = "customers"
End Sub
End Class