472,342 Members | 1,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

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 1581

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest...
6
by: leonecla | last post by:
Hi everybody, I'm facing a very very strange problem with a very very simple C program... My goal should be to write to a binary file some numbers...
2
by: Dave | last post by:
I build a very simple program that I put at the end of this post. This program is just supposed to put a button on the screen and exit the program...
0
by: roiavidan | last post by:
Hi, I'm having a bit of a problem with a small application I wrote in C#, which uses an Access database (mdb file) for storing financial data. ...
9
by: Vito DeCarlo | last post by:
I've been having this problem for a few weeks. PLEASE read this post before responding with some simple reason that has nothing to do with my...
0
by: tom | last post by:
Hallo, I need help on MIDI file, and precisely about retrieving few note values (mainly the "Velocity" value, corrisponding to the...
3
by: cold80 | last post by:
I was just doing a performance test in order to see the benefit of using AJAX instead of doing a postback on the server. So I have a simple page...
1
by: Ramsesz | last post by:
Hi all, I am new here (forgive me if I do not follow forum-rules which i am not yet familiar with). I have a problem that bugs me quite some time...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at...
5
by: Ibys | last post by:
Hi, i am just starting to learn javascript, so i am probably doing something very simple wrong. i have read a lot of articles on maths in java, but...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.