pre_wreck
April 10th, 2007, 03:02 AM
Kindly help me please.
I'm having some trouble in my code and I'm stack with this error.
// error: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
// Additional information: There is no row at position 0.
Here's the code.
private void tbSearchOption_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
long totalRow = 0;
//Set the Data Adapter
OleDbDataAdapter da = new OleDbDataAdapter("SELECT qryStudentInfo.StudentNo, qryStudentInfo.Name, qryStudentInfo.Degree FROM qryStudentInfo WHERE qryStudentInfo.StudentNo LIKE '" + txtSearch + "' ",mdlConnection.conn);
DataSet ds = new DataSet();
da.Fill(ds,"qryStudentInfo");
totalRow = ds.Tables["qryStudentInfo"].Rows.Count -1;
if(e.Button == tbSearch)
{
if (txtSearch.Text == "")
MessageBox.Show("Please select a search field!", "Empty search field", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
{
if (cboSearchBy.SelectedIndex == 0)
{
txtStudID.DataBindings.Clear();
txtStudID.Text = ds.Tables["qryStudentInfo"].Rows[0].ItemArray.GetValue(0).ToString();
// error: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
// Additional information: There is no row at position 0.
}
else
{
dr = mdlProd.FillStudentsSearchBy(cboSearchBy, txtSearch.Text);
mdlFunc.FillRecords(lvStudents,dr);
}
}
}
else if(e.Button == tbBrowse)
{
MessageBox.Show("Reset!", "Reset...", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
I'm having some trouble in my code and I'm stack with this error.
// error: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
// Additional information: There is no row at position 0.
Here's the code.
private void tbSearchOption_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
long totalRow = 0;
//Set the Data Adapter
OleDbDataAdapter da = new OleDbDataAdapter("SELECT qryStudentInfo.StudentNo, qryStudentInfo.Name, qryStudentInfo.Degree FROM qryStudentInfo WHERE qryStudentInfo.StudentNo LIKE '" + txtSearch + "' ",mdlConnection.conn);
DataSet ds = new DataSet();
da.Fill(ds,"qryStudentInfo");
totalRow = ds.Tables["qryStudentInfo"].Rows.Count -1;
if(e.Button == tbSearch)
{
if (txtSearch.Text == "")
MessageBox.Show("Please select a search field!", "Empty search field", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
{
if (cboSearchBy.SelectedIndex == 0)
{
txtStudID.DataBindings.Clear();
txtStudID.Text = ds.Tables["qryStudentInfo"].Rows[0].ItemArray.GetValue(0).ToString();
// error: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
// Additional information: There is no row at position 0.
}
else
{
dr = mdlProd.FillStudentsSearchBy(cboSearchBy, txtSearch.Text);
mdlFunc.FillRecords(lvStudents,dr);
}
}
}
else if(e.Button == tbBrowse)
{
MessageBox.Show("Reset!", "Reset...", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}