RamHardikar
Programmer
Hi,
Below is a function that i call to get the rowcount. When it is called for the first time it returns me the rowcount. But when i call this for the 2nd time, it fails at ExecuteScalar() line of code and throws me an error (Object reference not set to an instance of an object). Could any one tell me why it fails?
Below is a function that i call to get the rowcount. When it is called for the first time it returns me the rowcount. But when i call this for the 2nd time, it fails at ExecuteScalar() line of code and throws me an error (Object reference not set to an instance of an object). Could any one tell me why it fails?
Code:
private int getRowCount(string strSQL)
{
OleDbConnection cn;
MyOleDBConnection OleDB = new MyOleDBConnection ("Provider=MSDAORA.1;User ID=test;Data Source=mydb;Password=test");
cn = OleDB.getMyOleDBConnection();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = strSQL;
cmd.Connection = cn;
int iRowCount = Int32.Parse(cmd.ExecuteScalar().ToString());
OleDB.closeDbConnection(cn);
return iRowCount;
}