I am trying to retrieve the information from a database table using SqlDataReader. I have two columns one string and the other is bit. The string will be filled in a textbox. But the problem with the bit when I wanted to fill it on a radiobuttonlist it doesn't happen. It keep giving me this error Specified cast is not valid.
This is my vb server side code:
Dim dt As DataTable = New DataTable()
Dim command As New SqlCommand(query2, conn)
Dim param As New SqlParameter()
param.ParameterName = "@cUserName"
param.Value = Session("Edit")
command.Parameters.Add(param)
Dim dr As SqlDataReader = command.ExecuteReader()
If dr.HasRows Then
dr.Read()
tbUsername.Text = dr.GetString(0)
rblDept.SelectedIndex = dr.GetByte(1)
End If
I tried dr.GetByte(1)
but it doesn't work. Help me please.