I developed an application using Microsoft access as the database but now i want to switch to sql compact edition.
My code is as under
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dr As SqlCeDataReader
Try
con.Open()
sql = "select userid from login where utype = 'Admin'"
cmd = New SqlCeCommand(Sql, con)
dr = cmd.ExecuteReader
If dr.HasRows = True Then
While dr.Read
uid = dr.GetString(0)
End While
Else
End
End If
dr.Close()
Catch ex As Exception
MessageBox.Show("Db is CLosed " + ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
fillUid()
End Sub
Im getting an exception here as under
SQL Server Compact does not support calls to HasRows property if the underlying cursor is not scrollable.
Detail of Exception
System.InvalidOperationException was caught
Message="SQL Server Compact does not support calls to HasRows property if the underlying cursor is not scrollable."
Source="System.Data.SqlServerCe"
StackTrace:
at System.Data.SqlServerCe.SqlCeDataReader.get_HasRows() at WindowsApplication1.Login.Login_Load(Object sender, EventArgs e) in C:\Users\kashif\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Login.vb:line 39
InnerException:
Please help me out of this problem