SQL Mobile Field Content

  • Thread starter Thread starter Beebs
  • Start date Start date
B

Beebs

How can I get the contents of a field in SQL Mobile. I've just
switched over from doing ADOCE projects so I'm quite clueless.

For instance, I use to be able to do this:

rs.Open(sqlString)
If Not rs.EOF And Not rs.BOF Then
If variable1 <> rs.Fields("Field1").Value.ToString() Then
'Do something
Else
'Do something
End If
End If
rs.Close()

In SQL Mobile programming, I can't even figure out how to tell if
there is a record in the query I set up in code. Can anyone give me
some minor assistance with this?

Thanks
 
Sample from
http://msdn2.microsoft.com/en-us/library/system.data.sqlserverce.sqlcedatareader.aspx

Dim conn As SqlCeConnection = Nothing
Dim cmd As SqlCeCommand = Nothing
Dim rdr As SqlCeDataReader = Nothing

Try
' Open the connection and create a SQL command
'
conn = New SqlCeConnection("Data Source = AdventureWorks.sdf")
conn.Open()

cmd = New SqlCeCommand("SELECT * FROM DimEmployee", conn)

rdr = cmd.ExecuteReader()

' Iterate through the results
'
While rdr.Read()
Dim employeeID As Integer = rdr.GetInt32(0) ' or:
rdr["EmployeeKey"];
Dim lastName As String = rdr.GetString(5) ' or: rdr["FirstName"];
End While

' Always dispose data readers and commands as soon as practicable
'
rdr.Close()
cmd.Dispose()
Finally
' Close the connection when no longer needed
'
conn.Close()
End Try


--
Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Back
Top