By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

problem with OleDbDataAdapter

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.