Hi all

If you have a function that return the dataset

you are using the oleddataadapter and the oledbconnection in it.

all code in the try catch block

In finally statement I am closing the connection, but oledbdataadapter.Dispose is necessary or not?



c# Code:
  1. public DataSet ListItems(long cartId, long userId)
  2.         {
  3.             this._cartId = cartId;
  4.             this._userId = userId;
  5.             con.Open();
  6.            
  7.             try
  8.             {
  9.                 OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Cart where nCartID='" + cartId + "' And nUserID='" + userId + "'", con);
  10.                 DataSet ds = new DataSet();
  11.                 adapter.Fill(ds);
  12.                 return ds;
  13.                
  14.             }
  15.             catch (Exception ex)
  16.             {
  17.                 throw ex;
  18.             }
  19.             finally
  20.             {
  21.                 con.Close();
  22.              
  23.             }
  24.  
  25.         }