SQL Compact Database larger than configured size

旧时模样 提交于 2019-12-12 20:09:34

问题


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 = " + strPassword + ";";
        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 .


回答1:


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

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



回答2:


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



来源:https://stackoverflow.com/questions/4601706/sql-compact-database-larger-than-configured-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!