0

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();
        }
3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Cameronsmith63
0

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.

0
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
                {
                }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.