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);
            con.Open();
          OleDbDataReader  rd = da.SelectCommand.ExecuteReader();

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

Recommended Answers

All 2 Replies

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);

                try
                {
                    AddTermTable.Clear();
                    myCommand.Fill(AddTermTable);
                    AddTermGrid.DataSource = AddTermTable;
                    QuanCount2.Clear();
                    string NumOfDevices = AddTermTable.Rows.Count.ToString();
                    FileName = NumOfDevices;
                }

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

                finally
                {
                }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.