Fill the Dataset
Posted by: Seng Kok Song
Date: January 10, 2005 04:32AM

Hi,

currently i am connecting to MSSQL 4.2.1 , ODBC 3.51.

i have written a C# application using Select statement to compare the records in MYSQL as below

f_PrevDate = f_CurrentGenerateDate.AddDays (-8) ;

while (f_DuplicatedRecord)
{
//Loop Previous issue date till Current Date (to compare the past records with most current date record)

while (f_PrevDate < f_CurrentGenerateDate )
{
//if record found in the Previous issue date
if (RecordFound(p_CommentType,p_PredictNo,GlobalVar.ConvertedDate f_PrevDate.ToString()),f_PickedNo))
{
f_DuplicatedRecord = true ;
break ;
}
else
{
//Record not found
f_DuplicatedRecord = false ;
}
//increase one day to the Previous date
f_PrevDate = f_PrevDate.AddDays (1) ;
}


}

updaterecord (p_currentdate) ;
f_DuplicatedRecord = true

________________________________________________________________
and this is the function that i written for executing the SQLstatment
#region Search records in predictreport table

public bool RecordFound (GlobalVar.PredictionType p_PredictType,string p_PredictNo,int p_SelectedNo,string p_Date,string p_Mode)
{
bool f_rtnResult = true ;
m_ErrorMsg = "NA" ;

try
{
m_DS = m_DBAcess.ExecuteSQLQuery (ComparePreviousRecord (p_PredictType ,p_PredictNo ,p_SelectedNo,p_Date,p_Mode)) ;
//ERROR occur in below statement
if (m_DS != null)
{
if (m_DS.Tables[0].Rows.Count > 0)
{
if (m_DS.Tables[0].Rows[0][0].ToString () != "")
{
f_rtnResult = true ;
m_DS.Clear ();
}
else
{
f_rtnResult = false;
m_DS.Clear ();
}
}
else
{
f_rtnResult = false ;
m_DS.Clear ();
}
}
}
catch (Exception e)
{
MessageBox.Show ("re"+ e.Message) ;
}
return f_rtnResult ;
}

functions to fill the dataset
public virtual DataSet ExecuteSQLQuery(string p_CommandText)
{
m_DataRecord = new DataSet ();

try
{
if (OpenDB())
{
m_OdbcCommand.CommandText = p_CommandText;
m_OdbcCommand.Connection = m_OdbcConnection ;
m_OdbcDataAdapter.SelectCommand = m_OdbcCommand ;

m_OdbcDataAdapter.Fill(m_DataRecord,"Table");
CloseDB();
//f_ExcRtn = true ;

}
}
catch(Exception e)
{
m_ExecuteErrorMsg = e.Message ;
CloseDB();
//f_ExcRtn = false ;
m_DataRecord = null ;

}

return m_DataRecord ;
}

after some time of the loop , a error message display "Cannot find table 0" .
and i try to trace the program , the problems happen in the dataset (m_DS != null).
but when i test in MS access , it work prefectly .

any one facing with this issue before ? and any solution on this issue ?

thankyou

Options: ReplyQuote


Subject
Written By
Posted
Fill the Dataset
January 10, 2005 04:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.