I am new to c# and have (through help on this website ;o) ) created a function which connects to a database and performs an sql query.
this is fine for updates and inserts, but when I need to return data it doesn't work like I want it, I get errors because the code in the function is closing the connection, so the returned data 'expires'
here is the code:
public OleDbDataReader data_sql(string strsql)
OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\mydata.mdb");
OleDbCommand cmd = new OleDbCommand(strsql);
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = connection;
OleDbDataReader reader = default(OleDbDataReader);
reader = cmd.ExecuteReader();
how can I get the returned data available outside of the function?