Fill 方法的使用是否有限制或注意事项【SQLite.net中的SQLiteDataAdapter类里的方法】

jiakehuigui 2009-10-14 10:15:46
各位大侠:
目前遇到这样的一个问题,在c#中我引进了sqlite.net后然后在使用fill(datatable)数的时候发现了一个问题,就是实际获取的数据表与数据库的数据不一致。数据库里大概有700条数据,但是通过fill方法获取的的数据才20条左右。请问是否是说fill方法在使用中我忽略了应该注意到的事项吗???
...全文
145 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiakehuigui 2009-10-14
  • 打赏
  • 举报
回复
 
public static DataTable GetDataTable(string strSql, out string strMsg)
{
strMsg = "";
DataTable dt = null;
try
{
if (m_conn == null)
{
strMsg = GetConnection();
if (strMsg != "")
{
dt = null;
throw new Exception(strMsg);
}
}

if (strMsg == "" && m_conn.State != ConnectionState.Open)
{
m_conn.Open();
}
SQLiteCommand cmd = new SQLiteCommand();

cmd.Connection = m_conn;

cmd.CommandText = strSql;

SQLiteDataAdapter da = new SQLiteDataAdapter();

da.SelectCommand = cmd;

dt = new DataTable();

da.Fill(dt);//在这边调用会发现无法获取到完整的数据列表
}
catch (Exception e)
{
strMsg = e.Message.ToString();
}
finally
{
m_conn.Close();
m_conn = null;
}
return dt;
}


请大侠们指点迷津。
Derekfan 2009-10-14
  • 打赏
  • 举报
回复

我这边有测试过,发现没有什么问题?你看看是否是你的查询到的数据有问题呢?你有捕获到什么异常呢?
Derekfan 2009-10-14
  • 打赏
  • 举报
回复
接分

17,741

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧