Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#35 Open Connection Prior to Update

open-rejected
nobody
None
5
2005-06-07
2005-05-04
Sunit Joshi
No

It seems you need to explicitly call a Conn.Open()
before you do any Updates using DataAdapter.
For Just Select; i.e. adapter.Fill you need not do it
though. I have to use this during Update:

if(oConn.State==ConnectionState.Closed)
oConn.Open();

lblStatus.Text = string.Format("Updated {0} records...",
oAdapter.Update(dSet, "Customers"));

if(oConn.State==ConnectionState.Open)
oConn.Close();

Discussion

  • Robert Foster
    Robert Foster
    2005-06-07

    Logged In: YES
    user_id=526041

    I'm not sure that this is a bug, the connection must be open
    anytime you operate on the data.

     
  • Robert Foster
    Robert Foster
    2005-06-07

    • status: open --> open-rejected
     
  • Sunit Joshi
    Sunit Joshi
    2005-06-07

    Logged In: YES
    user_id=1272454

    Actually not necessary. The DataAdapter, by it's definition,
    will Open a Connection object if it's not and then Close it
    when done.

     
  • Robert Foster
    Robert Foster
    2005-06-07

    Logged In: YES
    user_id=526041

    Nowhere in the documentation have I seen a statement that
    states that the DataAdapter will open the Connection object.
    Could you point me to the source of your assertion?
    Thanks.