SQL Server CE:没有足够的存储空间来完成该操作[CODE:8007000E]

如果你编写的 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
posted @ 2007-01-28 00:07 黎波 阅读(1330) 评论(6)  编辑 收藏 网摘 所属分类: SQL Server Compact

  回复  引用  查看    
#1楼2007-01-29 13:24 | sdxd.bgl      
这个地方使用using也是好的。
  回复  引用  查看    
#2楼[楼主]2007-01-29 14:18 | Bob Li      
@sdxd.bgl
如果同时存在SelectCommand、InsertCommand、UpdateCommand 和 DeleteCommand的时候,用using就不太好处理。

  回复  引用  查看    
#3楼2007-01-31 17:46 | LIVE      
现实调用Dispose()在此相当有用,我也遇见过类似问题,解决方案类似!:)
  回复  引用    
#4楼2007-04-11 20:27 | brace[未注册用户]
小弟问一下,使用c#可以这样解决,但是通过c plas plas使用ole db 怎么解决呀,急求!以前有没有遇到过,我的mail,wangangzhe@gmail.com.谢谢了
  回复  引用  查看    
#5楼[楼主]2007-04-11 21:25 | Bob Li      
@brace
你是不是没有释放内存?或者在一个事务做太多数据操作?

  回复  引用    
#6楼2007-08-29 11:24 | xx[未注册用户]
问题没解决



发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 632278




相关文章:

相关链接: