dataAdapter.Fill(m_DataSet) error

Joined
Jan 27, 2005
Messages
9
Programming Experience
1-3
hi i just followed the steps for a simple application that adds and delete records. Unfortunately, i have no idea why an error keeps on coming and it displays this:

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll

and it highlights this code dataAdapter.Fill(m_DataSet)

VB.NET:
 [size=2]
[/size][size=2][color=#008000][/color][/size] 
[size=2][color=#008000][size=2][color=#0000ff]Imports[/color][/size][size=2][color=#000000] System.Data.OleDb[/color]

[/size][size=2][color=#0000ff]Public[/color][/size][size=2][color=#000000] [/color][/size][size=2][color=#0000ff]Class[/color][/size][size=2][color=#000000] Form1[/color]

[/size][size=2][color=#0000ff]Inherits[/color][/size][size=2] System.Windows.Forms.Form

[/size][size=2][color=#0000ff]

[/color][/size][size=2][/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Const[/color][/size][size=2] APP_TITLE = "OrderEntry"

[/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Const[/color][/size][size=2] CONNECT_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Download\db1.mdb;"

[/size][size=2][color=#008000]'Objects that work with the database

[/color][/size][size=2][/size][size=2][color=#0000ff]Private[/color][/size][size=2] m_DataSet [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] DataSet

[/size][/color][/size][size=2][color=#008000]'Load a table into the DataSet
[/color][/size][size=2][/size][size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub[/color][/size][size=2] LoadTable([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] table_name [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][size=2], _

[/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] select_statement [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][size=2], [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] child_column_name [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][size=2], _

[/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] parent_table_name [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][size=2], [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] parent_column_name [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][size=2], _

[/size][size=2][color=#0000ff]ByRef[/color][/size][size=2] data_table [/size][size=2][color=#0000ff]As[/color][/size][size=2] DataTable, [/size][size=2][color=#0000ff]ByRef[/color][/size][size=2] dataAdapter [/size][size=2][color=#0000ff]As[/color][/size][size=2] OleDbDataAdapter)

[/size][size=2][color=#008000]'_Create a data adapter

[/color][/size][size=2]dataAdapter = [/size][size=2][color=#0000ff]New[/color][/size][size=2] OleDbDataAdapter(select_statement, CONNECT_STRING)

[/size][size=2][color=#008000]'_Create INSERT, UPDATE, and DELETE commands

[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] command_builder [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] OleDbCommandBuilder

[/size][size=2][color=#008000]'_Map the default table name "Table" to the table's real name

[/color][/size][size=2]dataAdapter.TableMappings.Add("Table", table_name)

[/size][size=2][color=#008000]'_Load the dataset

[/color][/size][size=2]dataAdapter.Fill(m_DataSet)

 

[/size][size=2][color=#008000]'_Save a reference to the new table

[/color][/size][size=2]data_table = m_DataSet.Tables(table_name)

[/size][size=2][color=#008000]'_Connect the tables with a foreign key constraint

[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] child_column_name.Length > 0 [/size][size=2][color=#0000ff]Then

[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] parent_table [/size][size=2][color=#0000ff]As[/color][/size][size=2] DataTable = m_DataSet.Tables(parent_table_name)

[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] foreign_key [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] ForeignKeyConstraint(parent_table.Columns(parent_column_name), data_table.Columns(child_column_name))

data_table.Constraints.Add(foreign_key)

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If

[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Sub

[/color][/size]

that's just the part of the code.. i hope you could help.
 
Back
Top