Using SqlCeDataReader

Hey Everyone,
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?
[1730 byte] By [lvance] at [2007-12-16]
# 1

You should read a record with rdrView.Read() first.
Check if it returns true indicating record is available.
If it is, you can access data with GetValue()
If your data can be null, check if it is using rdrView.IsDBNull()

IlyaTumanov at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...