SQL Server Compact版 [英] SQL Server Compact edition

查看:70
本文介绍了SQL Server Compact版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个使用Microsoft access作为数据库的应用程序,但现在我想切换到sql compact edition。

我的代码如下

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





我在这里得到一个例外,因为



SQL Server Compact如果基础光标不可滚动,则不支持调用HasRows属性。



例外详情



System.InvalidOperationException被捕获

Message =如果底层游标不可滚动,SQL Server Compact不支持对HasRows属性的调用。

Source =System.Data。 SqlServerCe

StackTrace:
$ C $ b,位于C:\\的WindowsApplication1.Login.Login_Load(Object sender,EventArgs e)的System.Data.SqlServerCe.SqlCeDataReader.get_HasRows() Users\kashif\Documents\Visu al Studio 2008 \Projects\WindowsApplication1 \ WindowsApplication1 \Login.vb:第39行

InnerException:







请帮我解决这个问题



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

推荐答案

我有完美的SQLCE Datareader解决方案....现在你可以像这样使用.................



Dim cmd作为SqlCeCommand

Dim dr作为SqlCeDataReader

Dim i As Int32 = 0

cmd =新SqlCeCommand(str,con)



dr = cmd.ExecuteResultSet(ResultSetOptions.Scrollable)

如果dr.HasRows = True则

else

endif





********************************** ** GC Kachhadia *************************
I Have Perfect Solution For SQLCE Datareader....Now You Can Use Like This.................

Dim cmd As SqlCeCommand
Dim dr As SqlCeDataReader
Dim i As Int32 = 0
cmd = New SqlCeCommand(str, con)

dr = cmd.ExecuteResultSet(ResultSetOptions.Scrollable)
If dr.HasRows = True Then
else
endif


************************************GC Kachhadia *************************


在打电话之前,你必须打电话给.Read。 HasRows
You have to call .Read before you call .HasRows


您好,

查看此

没有名为<的成员code> HasRows 在 .NET Compact Framework中。

http://msdn.microsoft.com/en-us/library/system.data。 sqlserverce.sqlcedatareader_members%28v = vs.71%29.aspx [ ^ ]

但是对于你的其余代码,我相信它会起作用,但有一些方法.NET Compact Framework不支持成员。

最好的问候

M.Mitwalli
Hi ,
Check this
There is no member called HasRows in .NET Compact Framework.
http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcedatareader_members%28v=vs.71%29.aspx[^]
but for the rest of your code i believe it will work but there is some methods and member not supported in .NET Compact Framework.
Best Regards
M.Mitwalli


这篇关于SQL Server Compact版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆