Regarding Fill method

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)
 
M

Miha Markic

Hi Lora,

Does it exception say anything more?
Could be that select statement is wrong?
Or the connection string?
 
L

Lora Connors

The Exception Message Is "An Unhandled Exception of Type
System.Data.Oledb.OleDbException Occured in The Insert.Exe"
 
B

Bernie Yaeger

Hi Lora,

Let's break this down. What is the insert.exe? (is the name of the
solution 'insert'? It may be a reserved word; change the name, for one
thing)

Also, do a try catch block around the fill method - I think the error may be
not in the .fill but rather in the insert. Let's at least determine that.

Bernie
 
M

Miha Markic

Let's break this down. What is the insert.exe? (is the name of the
solution 'insert'? It may be a reserved word; change the name, for one
thing)

I don't think that this is the problem - it is probably just assembly's name
:)
Also, do a try catch block around the fill method - I think the error may be
not in the .fill but rather in the insert. Let's at least determine that.

My feeling, too.
 
F

Frank Oquendo

Lora said:
Dim Insertvalues As Object() = {Autonumber,
txtMovieTitle.Text, txtCast.Text, CInt(cmbCopies.Text),
bolRating}

Assuming the purpose of the AutoNumber variable is self-explanatory, it
must be Nothing or your insert will fail.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 

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