Using SqlCeDataReader
I've got a datagrid that I am using to select a record to populate another screen. I'm able to create a SqlCeDataReader object using the value of the first column of the selected record in the datagrid, however, when I try to populate the contents of a label field, I get an error stating that there is no data in the selected column. Here is the code:
btnView.Enabled =False Dim cnWorkOrdersAs SqlCeConnection Dim woIDAsInteger cnWorkOrders =New SqlCeConnection("Data Source =\SD Card\My Documents\workorders.sdf;Password=") cnWorkOrders.Open() woID =Integer.Parse(grdResults.Item(grdResults.CurrentRowIndex, 0)) Dim cmdViewAs SqlCeCommand = cnWorkOrders.CreateCommand cmdView.CommandText = "SELECT * FROM SWWRKORD WHERE WOID = ?" cmdView.Parameters.Add("@WOID", woID) pnlResults.Visible =False pnlView.Location =New Point(0, 0) pnlView.Visible =True Dim rdrViewAs SqlCeDataReader rdrView = cmdView.ExecuteReader lblName.Text = rdrView.GetValue(0) |
What am I doing wrong?

