17,741
社区成员
发帖
与我相关
我的任务
分享
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;
}