Reputation: 1
Hi? Anyone could help me how to rewrite the following function publicly so I could call it from another form or class
DataTable GetData(string connstr, string qrystr)
{
var conn = new System.Data.OleDb.OleDbConnection(@connstr);
conn.Open();
OleDbCommand comm = new System.Data.OleDb.OleDbCommand(qrystr, conn);
DataTable dtbl = new DataTable();
dtbl.Load(comm.ExecuteReader());
return dtbl;
}
Upvotes: 0
Views: 28
Reputation: 222722
For a method, Private
is the default if no access modifier is specified.
To make it Public
Just add public
public DataTable GetData(string connstr, string qrystr)
{
var conn = new System.Data.OleDb.OleDbConnection(@connstr);
conn.Open();
OleDbCommand comm = new System.Data.OleDb.OleDbCommand(qrystr, conn);
DataTable dtbl = new DataTable();
dtbl.Load(comm.ExecuteReader());
return dtbl;
}
Upvotes: 1