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:
public DataSet ListItems(long cartId, long userId) { this._cartId = cartId; this._userId = userId; con.Open(); try { OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Cart where nCartID='" + cartId + "' And nUserID='" + userId + "'", con); DataSet ds = new DataSet(); adapter.Fill(ds); return ds; } catch (Exception ex) { throw ex; } finally { con.Close(); } }




Reply With Quote