各位大侠:
目前遇到这样的一个问题,在c#中我引进了sqlite.net后然后在使用fill(datatable)数的时候发现了一个问题,就是实际获取的数据表与数据库的数据不一致。数据库里大概有700条数据,但是通过fill方法获取的的数据才20条左右。请问是否是说fill方法在使用中我忽略了应该注意到的事项吗???
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;
}请大侠们指点迷津。
目前遇到这样的一个问题,在c#中我引进了sqlite.net后然后在使用fill(datatable)数的时候发现了一个问题,就是实际获取的数据表与数据库的数据不一致。数据库里大概有700条数据,但是通过fill方法获取的的数据才20条左右。请问是否是说fill方法在使用中我忽略了应该注意到的事项吗???
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;
}请大侠们指点迷津。
感动呀 终于来人了! sql语句只是简单的查询语句,我试验的语句是“select * from table”