469,631 Members | 1,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Very Simple Problem

Hello All,

Hope somebody wouldn`t mind helping me, i have a problem and as a newbie I
don`t know where im going wrong:

I keep getting the following error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" on the line
that says: "daPatientsIDs.Fill(dtPatientsIDs)"

When trying to run this Code:

'CODE START
Option Strict On
Imports System.Data.OleDb

Public Class Form1
Inherits System.Windows.Forms.Form

Dim dbConnection As OleDbConnection
Dim dbCommand As OleDbCommand
Dim dbDataAdapter As OleDbDataAdapter
Dim ConnectString As String = "Provider = Microsoft.Jet.OLEDB.4.0;" &
"Data Source = Hospital.MDB"
Dim dtPatientsIDs As New DataTable()
Dim daPatientsIDs As New OleDbDataAdapter("Select [Patients ID] from
Patients", ConnectString)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
daPatientsIDs.Fill(dtPatientsIDs)
lstPatientIDs.DataSource = dtPatientsIDs
lstPatientIDs.DisplayMember = "Patient ID"

OleDbDataAdapter.Fill(dsPatientsAndWards)

txtWardName.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward
Name")
txtWardType.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward
Type")

End Sub
End Class
'CODE FINISH

Anybody shed any light on this?

Regards
Merlin
Nov 20 '05 #1
5 1526

"Merlin" <te**@nospam.com> wrote in message
news:Rp********************@karoo.co.uk...
Hello All,

Hope somebody wouldn`t mind helping me, i have a problem and as a newbie I
don`t know where im going wrong:

I keep getting the following error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" on the line that says: "daPatientsIDs.Fill(dtPatientsIDs)"

You need to put your fill statement in a try block, that way you will get a
descriptive error. Something like this:

....
Try
OleDbDataAdapter.Fill(dsPatientsAndWards)
Catch Ex as Exception
Console.WriteLine("Error: " & ex.Message)
Msgbox("Error: " & Ex.Message)
End Try
....

Then run it again, and give us the descriptive error message.

~
Jeremy

Nov 20 '05 #2
"Merlin" <te**@nospam.com> schrieb

Hope somebody wouldn`t mind helping me, i have a problem and as a
newbie I don`t know where im going wrong:

I keep getting the following error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" on
the line that says: "daPatientsIDs.Fill(dtPatientsIDs)"


Already tried putting it in a try-catch block and examining the thrown
exception? Exception should contain details.

If it turns out to be an ADO.NET related question: Right group is
microsoft.public.dotnet.framework.adonet
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Jeremy i`ve put the code in Try Expressions like you said and it throws up:

"Additional information: This would cause two bindings in the collection to
bind to the same property." on:

txtWardName.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward
Name")
txtWardType.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward
Type")

In my book that im working from it say "In the Forms Load event, write the
following code to fill the dataset from the the data adapter and then to
bind the two textboxes displaying details about the wards to the ward name
and ward type fields in the dataset"

Thanks for you help so far

Ta
Merlin

"Merlin" <te**@nospam.com> wrote in message
news:Rp********************@karoo.co.uk...
Hello All,

Hope somebody wouldn`t mind helping me, i have a problem and as a newbie I
don`t know where im going wrong:

I keep getting the following error "An unhandled exception of type
'System.Data.OleDb.OleDbException' occurred in system.data.dll" on the line that says: "daPatientsIDs.Fill(dtPatientsIDs)"

When trying to run this Code:

'CODE START
Option Strict On
Imports System.Data.OleDb

Public Class Form1
Inherits System.Windows.Forms.Form

Dim dbConnection As OleDbConnection
Dim dbCommand As OleDbCommand
Dim dbDataAdapter As OleDbDataAdapter
Dim ConnectString As String = "Provider = Microsoft.Jet.OLEDB.4.0;" &
"Data Source = Hospital.MDB"
Dim dtPatientsIDs As New DataTable()
Dim daPatientsIDs As New OleDbDataAdapter("Select [Patients ID] from
Patients", ConnectString)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
daPatientsIDs.Fill(dtPatientsIDs)
lstPatientIDs.DataSource = dtPatientsIDs
lstPatientIDs.DisplayMember = "Patient ID"

OleDbDataAdapter.Fill(dsPatientsAndWards)

txtWardName.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward Name")
txtWardType.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward Type")

End Sub
End Class
'CODE FINISH

Anybody shed any light on this?

Regards
Merlin

Nov 20 '05 #4
"Merlin" <te**@nospam.com> wrote in message
news:mp********************@karoo.co.uk...
Jeremy i`ve put the code in Try Expressions like you said and it throws up:
"Additional information: This would cause two bindings in the collection to bind to the same property." on:

txtWardName.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward
Name")
txtWardType.DataBindings.Add("Text", dsPatientsAndWards, "Patients.Ward
Type")

In my book that im working from it say "In the Forms Load event, write the
following code to fill the dataset from the the data adapter and then to
bind the two textboxes displaying details about the wards to the ward name
and ward type fields in the dataset"

My *guess* is that your code is executing more than once, and doubling the
bindings, however this question really belongs in the ADO.NET Group:

microsoft.public.dotnet.framework.adonet
~
Jeremy

Nov 20 '05 #5
One other thing you might try is stepping through each line of code to see
exactly when it crashes. You can do this by selecting "Debug > Step Into"
on the main menu at Design Time (while the app is NOT running) or F8 if you
use VB Classic key bindings.

~
Jeremy

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dave | last post: by
9 posts views Thread by Vito DeCarlo | last post: by
3 posts views Thread by cold80 | last post: by
112 posts views Thread by Prisoner at War | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.