the problem line is 'returnValue = sqlReader.GetValue(tmpInt)',vb.net Code:
Dim sqlCon As New SqlConnection("Data Source=ICYCULYR\SQLEXPRESS;Initial Catalog=test_kcDB;Integrated Security=True;Pooling=False") sqlCon.Open() Dim sqlCommand As New SqlCommand() sqlCommand.Connection = sqlCon Dim returnValue As Object = "Nothing" Select Case whichPreference Case PreferencesEnum.dblClickMenu sqlCommand.CommandText = ("SELECT preferences_value FROM dataTable") Dim sqlReader As SqlDataReader = sqlCommand.ExecuteReader() Dim tmpInt As Integer = 0 While sqlReader.Read() If tmpInt = whichPreference Then returnValue = sqlReader.GetValue(tmpInt) Exit While End If tmpInt += 1 End While End Select sqlCon.Close()
my value is DBNULL, but should return the first value of my column, which would be 'true'.
I assume sqlReader is reading the rows from my column 'preferences_value', so I don't see why it isn't working?
sqlReader.GetValue(tmpInt) (tmpInt being 0, as whichPreference is 0)
it should return the first row.
If anyone could help me with this?
Thanks




Reply With Quote