Declartion of DataAdapter.Fill

  • Thread starter Thread starter Lora Connors
  • Start date Start date
L

Lora Connors

I have created a form to insert records into Access
database without the Wizard. I have declared the
DataAdapter & DataTable variables in the Form Declarations
Section. If I use the Dataadapter.Fill method in the
Event Procedure 'Mybase.load'I get the message "Unhandled
OleDbException occurred in System.Data.dll ". Ditto if I
use the Fill method in the Click method of the 'Add'
command button. I need to know The Event in which I need
to use the Fill method.

Thanks!
 
Hi Lora,

Please show us the brief code that you developed - the fill method should
work anywhere, in any event of that form.

HTH,

Bernie Yaeger
 
I have written the following code to insert records into
Access database. If I use the DataAdapter.Fill method in
the Add Command button as shown below I get the
message "Unhandled OleDbException occurred in
System.Data.dll". Ditto if I use the Fill method in the
Event procedure MyBase.load.

'GENERAL DECLARATIONS

Dim daAddMovie As New OleDbDataAdapter _
("select MovieId,MovieTitle,Cast,No_of_Copies,Rating
from movies", strConnection)
Dim tblAddMovie As New DataTable("Movies")

'SUB TO ADD RECORD TO DATATABLE

PUBLIC SUB ADD(ByVal sender As Object, ByVal e As
System.EventArgs) handles cmdAdd.Click

daAddMovie.Fill(tblAddMovie) 'Fill the Datatable
Dim Insertvalues As Object() = {Autonumber,
txtMovieTitle.Text, txtCast.Text, CInt(cmbCopies.Text),
bolRating}
tblAddMovie.LoadDataRow(Insertvalues, False)
 
Back
Top