I am trying to make a function check if a record exits and if so, collect some data from it. Here is the code I have:
Public Function CheckExist(ByVal X As Double) As Boolean
'check if the record exists, if so get the data
Dim sql As String
Dim dr As SqlCeDataReader
Dim cmd As SqlCeCommand
sql = "SELECT * from TestPPC where AID = " & X
'select the data
Try
cmd = New SqlCeCommand(sql, SqlConn)
dr = cmd.ExecuteReader
Catch ex As Exception
MsgBox("Error in check exist")
CheckExist = False
Exit Function
End Try
'try reading a record
Try
MsgBox("A1")
dr.Read()
LastBurstCount = dr.GetValue(Col_BurstCount)
MsgBox("A3")
'get current data
With D
.WSN = dr.Item("WSN").ToString
MsgBox("B")
If Not (dr.GetValue(Col_User) Is Nothing) Then .User = CStr(dr.GetValue(Col_User))
MsgBox("C")
.BCount = dr.GetValue(Col_BCount)
MsgBox("D")
.SCount = CDbl(dr.GetValue(Col_SCount))
MsgBox("E")
End With
Catch ex As Exception
CheckExist = False
MsgBox("Error setting data")
Exit Function
End Try
CheckExist = True
End Function
The Col_ variables are constants to the field numbers. The message boxes that are shown are : A1, A3, and B. So I think there is an error in the line after MsgBox("B"). I have the if statement to check for a null because User can be (and is currently) a null.
This may seem like a dumb question, but what is the method of database interaction that I am using called? I don't think it is ADOCE or RDA. Trying to search on google is very difficult since I don't know the name. The Microsft tutorial I used just went right into the examples and didn't say. I think I'm confusing myself by reading articles for different methods. Thanks for the help.