开发者

SQL Compact Database larger than configured size

I'm trying to search a mobile SDF database in Windows Mobile 6.1 and the database is about 270MB. Whenever the program tries to read from the database I get this error:

"The database file is larger than the configured size.

This settings takes effect on the first concurrent database connection only [Required Max Database Size (in MB; 0 if unknown) =0]"

I tried specifying the size in the connection string but I get an error as well:

public bool ConnectDB(string strDB, string strPassword)
{
    try
    {
        string siz= "300";
        string connStr = "Data Source = " + strDB + "; Size = " + siz + "; Password = " + strPasswor开发者_如何学God + ";";
        ceConnection = new SqlCeConnection(connStr);
        ceConnection.Open();
        if (ceConnection.State == System.Data.ConnectionState.Open)
            return true;
    } catch () {}
}

I get unknown connection option in connection string: Size.

Please help .


You must use "Max database size" (in MB)

"Data Source = " + strDB + "; Max Database Size = " + siz 


270 MB is way to large for a mobile database. Have you tried compressing it? You can use the SqlCeEngine class. Try Shrink() or Compact()

http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceengine.shrink.aspx

http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceengine.compact.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜