473,386 Members | 1,804 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,386 software developers and data experts.

problem with OleDbDataAdapter

hi all.
i wrote this code and i get an error msg:
Private Pr_MyCon As new System.Data.OleDb.OleDbConnection
Private Pr_DataSet As new DataSet("Temp")
Private Pr_DataAdapter As
system.Data.OleDb.OleDbDataAdapter

Pr_MyCon.ConnectionString ="....."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_MyCon.open()
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the eror msg syas:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"
why?

Nov 21 '05 #1
3 1910
The most likely cause is that you are explicitly opening the databse and tha
DataAdapter is spitting it's dummy because the connection is already open
when it attempts to execute the Fill method.

The DataAdapter will open and close the connection as required.

Remove your explicit open and all should be well.
"shachar" <an*******@discussions.microsoft.com> wrote in message
news:22****************************@phx.gbl...
hi all.
i wrote this code and i get an error msg:
Private Pr_MyCon As new System.Data.OleDb.OleDbConnection
Private Pr_DataSet As new DataSet("Temp")
Private Pr_DataAdapter As
system.Data.OleDb.OleDbDataAdapter

Pr_MyCon.ConnectionString ="....."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_MyCon.open()
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the eror msg syas:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"
why?

Nov 21 '05 #2
Shachar,

In addition to Stephany,

A connection needs for every open an close (or with the connection better
instead of that a dispose and when you do that, you have to add the
connectionstring again).

Told is that the best practise of that is:
With anything else than a dataadapter just to do that open and dispose
consequently.
With a dataadapter with one fill let it be done by the dataadapter
With a dataadapter with a lot of sequential fills do an open and dispose
consequently

However never leave you connection open when it is not doing something.

(With the exception for an access database to prevent deleting that in the
meantime, however than you have to set the connection in the load event and
the close in the closing event)

I hope this helps?

Cor
"shachar" <an*******@discussions.microsoft.com>
hi all.
i wrote this code and i get an error msg:
Private Pr_MyCon As new System.Data.OleDb.OleDbConnection
Private Pr_DataSet As new DataSet("Temp")
Private Pr_DataAdapter As
system.Data.OleDb.OleDbDataAdapter

Pr_MyCon.ConnectionString ="....."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_MyCon.open()
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the eror msg syas:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"
why?

Nov 21 '05 #3
i took off the connection implicit opening - BUT it still
gives the same error msg!!
why?
-----Original Message-----
The most likely cause is that you are explicitly opening the databse and thaDataAdapter is spitting it's dummy because the connection is already openwhen it attempts to execute the Fill method.

The DataAdapter will open and close the connection as required.
Remove your explicit open and all should be well.
"shachar" <an*******@discussions.microsoft.com> wrote in messagenews:22****************************@phx.gbl...
hi all.
i wrote this code and i get an error msg:
Private Pr_MyCon As new System.Data.OleDb.OleDbConnection Private Pr_DataSet As new DataSet("Temp")
Private Pr_DataAdapter As
system.Data.OleDb.OleDbDataAdapter

Pr_MyCon.ConnectionString ="....."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_MyCon.open()
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the eror msg syas:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"
why?

.

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aaron Smith | last post by:
I can't seem to get my table styles to apply to my DataGrid. In order for them to apply correctly, what exactly has to be set in the DataSource and DataMember, and then the DataMapping properties?...
2
by: Mika M | last post by:
My contact has really old Access 2.0 database still in their production use, and application which uses that is propably made by VB5 or VB6. Now I should to do few SQL-queries and make charts...
0
by: A.J | last post by:
There is a : 1.DataGrid: Columns-->firstName,LastName,EMail,PhoneNumber 2.GroupBox: controls-->4 TextBoxes(firstName,LastName,EMail,PhoneNumber) 3.Both DataGrid and GroupBox are binded to the...
1
by: gkellymail | last post by:
I currently have a class with 29 data adapters and I will probably add a few more as time goes on. When I was testing earlier, i had 28 of them pointing to one connection and 1 pointing to a...
2
by: Scotty | last post by:
I get stuck to write an update, insert and delete command, i am looking for some help to start Whats the best way to update 2 tables toe the database (Access) below my code used to load my...
3
by: Mitch W | last post by:
Consider the following: I have two Access tables: TableA & TableB TableA is a list of Names with a ZipID TableB is a list of City, States, and Zips with a ZipID as a primary key...
1
by: explode | last post by:
I made a oledbdataadapter with this code Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) Dim i As Integer Dim nova As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter Dim veza...
1
by: dhyder | last post by:
OK, like the title says my error is Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. I have looked into this a lot, but have not...
13
by: slinky | last post by:
I'm working on a problem with a form with 6 textboxes and a submit button for adding data to an Access database.I changed a few things and got it down to 1 error!. I have a Sub Page_Load and a Sub...
0
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.