Declartion of DataAdapter.Fill

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!
 
B

Bernie Yaeger

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
 
L

Lora Connors

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top