473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1618

"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 week (when the db grow a lot). The DB is around...
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 (integers), each one represented as a sequence...
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 when I press the escape button. But pressing the...
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. After looking for a similiar topic and failing to...
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 problem. If you need more information, please request...
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 intensity of a played note) while the MIDI is playing.
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 that performs a request to the server and write a...
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 now. I did not find any solutions on the net, so...
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 http://buildit.sitesell.com/sunnyside.html does not...
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 cant find anything simple enough for my problem. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.