日期:2014-05-17 浏览次数:20845 次
private void initalDataSource()
{
try
{
//两个表,tezb和submonth,通过smonth字段关联。
loop: string selectCount = "SELECT count(*) FROM tezb t left join submonth s on t.smonth=s.smonth ......";
string sql = selectCount.Replace("count(*)", "t.rowid,t.stype,t.sjindu,t.smonth,sid,fkid,sleiji,sbyl,sbenjia,sbdjc,sbjc");
int count = Convert.ToInt32(SqliteHelper.ExecuteScalar(sqlconn.conn, selectCount + " and t.stype!=''"));
DataSet ds = new DataSet();
if (count > 0)
ds = SqliteHelper.getDataset(sqlconn.conn, CommandType.Text, sql + " and t.stype!=''", null);
else
ds = SqliteHelper.getDataset(sqlconn.conn, CommandType.Text, sql, null);
if (ds.Tables.Count > 0)
dt = ds.Tables[0];
if (dt.Rows.Count == 0)
{
//有些数据在因为tezb表中没有数据,上面读取不到,在这里补充数据。
string insertTezb = "insert into tezb(sgroup,smonth) select ...." ;
SqliteHelper.ExecuteNonQuety(sqlconn.conn, insertTezb);