AndiZul
AndiZul

Reputation: 1

Need help to declare public function or method

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

Answers (1)

Sajeetharan
Sajeetharan

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

Related Questions