首 页 | 新 闻 | Symbian | Windows Mobile| J2ME | 下载中心 | 游戏策划 | 购书指南 | 移动开发视频教程
您现在的位置: 开发视界 >> Windows Mobile >> SQL Server CE >> 文章正文
SQL Server CE:没有足够的存储空间来完成该操作[CODE:8007000E]
作者:黎波    文章来源:http://www.cnblogs.com/upto/archive/2007/01/28/kb-824462.html    更新时间:2007-11-6 8:41:12

如果你编写的 SQL Server CE 应用程序出现下面的错误信息:

   Error Code: 8007000E
   Message: Not enough storage is available to complete this operation.
   Minor Err.:0 Source: Microsoft SQL Server 2000 Windows CE Edition

或者

   Error Code: 8007000E
   Message: 没有足够的存储空间来完成该操作。
   Minor Err.:0 Source: Microsoft SQL Server 2000 Windows CE Edition

可能是以下原因导致的:
你在使用 SqlCeDataAdapter 对象填充 DataSet 后,没有显式地调用相关 SqlCeCommand 对象的 Dispose 方法。

解决方法:
在使用完 SqlCeDataAdapter 对象后,显式地调用与 SqlCeDataAdapter 对象相关的 SqlCeCommand 对象的 Dispose 方法。包括有 SelectCommand、InsertCommand、UpdateCommand 和 DeleteCommand。

示例代码:

public static DataSet LoadData()
{
    
string sqlstring = ""
;

    
//  Make the connection to the SQL Server CE data source

    SqlCeConnection conn = new SqlCeConnection("Data Source=<completePath of SDF file>");
    
//  Create the SqlCeDataAdapter object

    sqlCeDataAdapter da = new SqlCeDataAdapter();
    
//  Create the DataSet object

    DataSet ds = new DataSet();

    
try

    {
        sqlstring 
= "select name from mytable where name = ?";

        
// Create the SelectCommand instance to run a select query

        da.SelectCommand = new SqlCeCommand();

        
// Set SelectCommand object properties

        da.SelectCommand.Connection = conn;
            da.SelectCommand.CommandText 
=
 sqlstring;
        da.SelectCommand.Parameters.Add(
new  SqlCeParameter("name", System.Data.SqlDbType.NVarChar, 30
));
        da.SelectCommand.Parameters[
"name"].Value =
 name;

        
//  Populate the DataSet object

        da.Fill(ds,"name");
    }
    
catch
 (SqlCeException sqlx)
    {
        ShowErrors(sqlx);
    }
    
catch
 (Exception x)
    {
        MessageBox.Show(x.Message.ToString());
    }
    
finally

    {
        
//  Explicitly dispose the SelectCommand instance
        da.SelectCommand.Dispose();
        da.Dispose();
    }

    
return
 ds;
}

参考微软知识库:
SqlCeCommand objects are not automatically disposed if you use a SqlCeDataAdapter object
相关文章:
使用 ASP.NET 2.0 进行移动 Web 开发
SQL Server Mobile 开发基础 ppt 和 demo
用SQL Server Compact创建简单的Windows应用程序
用 SQL Server Everywhere 保存离线数据
基于SQL Server CE的移动服务系统开发
利用RDA实现SQL CE与桌面SQL Server数据库间的数据存取
SQL Server Mobile 开发基础  ppt 和 demo
用SQL Server Compact创建简单的Windows应用程序