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?