473,786 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ol eDb.OleDbExcept ion' occurred in system.data.dll " on the line
that says: "daPatientsIDs. Fill(dtPatients IDs)"

When trying to run this Code:

'CODE START
Option Strict On
Imports System.Data.Ole Db

Public Class Form1
Inherits System.Windows. Forms.Form

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

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
daPatientsIDs.F ill(dtPatientsI Ds)
lstPatientIDs.D ataSource = dtPatientsIDs
lstPatientIDs.D isplayMember = "Patient ID"

OleDbDataAdapte r.Fill(dsPatien tsAndWards)

txtWardName.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard
Name")
txtWardType.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard
Type")

End Sub
End Class
'CODE FINISH

Anybody shed any light on this?

Regards
Merlin
Nov 20 '05 #1
5 1644

"Merlin" <te**@nospam.co m> wrote in message
news:Rp******** ************@ka roo.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.Ol eDb.OleDbExcept ion' occurred in system.data.dll " on the line that says: "daPatientsIDs. Fill(dtPatients IDs)"

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

....
Try
OleDbDataAdapte r.Fill(dsPatien tsAndWards)
Catch Ex as Exception
Console.WriteLi ne("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.co m> 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.Ol eDb.OleDbExcept ion' occurred in system.data.dll " on
the line that says: "daPatientsIDs. Fill(dtPatients IDs)"


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.publi c.dotnet.framew ork.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.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard
Name")
txtWardType.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard
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.co m> wrote in message
news:Rp******** ************@ka roo.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.Ol eDb.OleDbExcept ion' occurred in system.data.dll " on the line that says: "daPatientsIDs. Fill(dtPatients IDs)"

When trying to run this Code:

'CODE START
Option Strict On
Imports System.Data.Ole Db

Public Class Form1
Inherits System.Windows. Forms.Form

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

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
daPatientsIDs.F ill(dtPatientsI Ds)
lstPatientIDs.D ataSource = dtPatientsIDs
lstPatientIDs.D isplayMember = "Patient ID"

OleDbDataAdapte r.Fill(dsPatien tsAndWards)

txtWardName.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard Name")
txtWardType.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard Type")

End Sub
End Class
'CODE FINISH

Anybody shed any light on this?

Regards
Merlin

Nov 20 '05 #4
"Merlin" <te**@nospam.co m> wrote in message
news:mp******** ************@ka roo.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.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard
Name")
txtWardType.Dat aBindings.Add(" Text", dsPatientsAndWa rds, "Patients.W ard
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.publi c.dotnet.framew ork.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
21347
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 250G, and has one table with 1 billion rows. It is performing in a decent way, but can't understand why a particolar table has strong performance problem.
6
8537
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 of 32 bit. I made this stupid trial code: --------------------------------------------- FILE *fout;
2
1694
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 escape button doesn't do anything if I put the code for the button into the program! infact, pressing escape only works if you take away the little piece of code: "this.Controls.Add(this.button1);"!! I was totally confused at why this happened...
0
2625
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 find one, I'm posting the question in hope some one of you guys out there will have the answer for me...! I'll start with what I have, then I'll continue to the problem itself.
9
10508
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 it as I'll be checking this post very often. PROBLEM: Occaisionally, our web server begins running ASP.NET pages extremely slowly. Other websites on the server run fine, including ASP pages. It almost seems as if the .NET caching system...
0
1750
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
7572
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 counter on the page when it receives the response from the server. I'm not changing the page actually, so the browser don't have to modify the internal DOM and to render the changes. I tried this simple page with IE 7.0, Firefox 2.0 and Opera 9.10....
1
2253
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 I hope you guys can help me out! I have a very simple html form (for test purposes): <form method='post' action='processForm.asp'> <input type='text' name='email' /> <input type='submit' value='submit' /> </form>
112
4761
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 work. To rule out all possible factors, I made up a dummy page for an index.html to upload, along the lines of <html><head><title></title></ head><body></body></html>.; the image-swap itself is your basic <img src="blah.png"...
5
1760
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 am looking for how to get an IF statement to give me the correct output. I am trying to get it to give me a result for a weeks pay, taking that the code worked before i tried to add the IF statement, to make it that if HoursWorked >= 20, the rate of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.