Hi all

when i execute my code it gives me this error " no data exists for the row column"

can anyone please help me,,,am using access database

here is my code:

private void UpdateStudent_Load(object sender, EventArgs e)

            OleDbDataAdapter da = new OleDbDataAdapter();
            da.SelectCommand = new OleDbCommand("select * from Students where SID= " + U_ID, con);
          OleDbDataReader  rd = da.SelectCommand.ExecuteReader();

            if (rd.Read())
                //txtId.Text = U_ID;
                txtId.Text = rd["SID"].ToString();

What data type is SID? It may require quotes around it (i.e. is varchar or similar). Secondly, try da.Fill() and see if that fills the dataset which is an option rather than using a dataAdapter to populate a reader.

OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FileAddress.Text + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1;MAXSCANROWS=0\"");
                OleDbDataAdapter myCommand = new OleDbDataAdapter(" SELECT TERM_NR FROM [To be Scheduled$]", conn);

                    AddTermGrid.DataSource = AddTermTable;
                    string NumOfDevices = AddTermTable.Rows.Count.ToString();
                    FileName = NumOfDevices;

                catch (Exception ex)
                    string exce = ex.Message;

This article has been dead for over six months. Start a new discussion instead.