標籤:lin and .com ble new close ati null name
有的時候我們需要在ADO.NET中同時執行多條的SQL文法,我們要如何處理,
例如下:
//查詢基本資料 private static void TestQry() { DataTable dtReturn =new DataTable(); //查詢基礎資料 try { //模擬查詢原始資料 string strSql1 = @"Select id,name from [email protected]:tablenameunionSelect id,name from [email protected]:tablenameinto temp tmp_tablename with no log;"; string strSql2 = @"select * from tmp_tablename;"; string strSql3 = @"drop table tmp_tablename;"; using (IfxConnection conn = new IfxConnection(gsConnStr)) { using (IfxCommand cmd = new IfxCommand(strSql1, conn)) { conn.Open(); // cmd.CommandType = CommandType.Text; cmd.CommandText = strSql1; cmd.ExecuteNonQuery(); using (IfxDataAdapter ad = new IfxDataAdapter(strSql2, conn)) { ad.Fill(dtReturn); } cmd.CommandType = CommandType.Text; cmd.CommandText = strSql3; cmd.ExecuteNonQuery(); conn.Close(); } } } catch (Exception ex) { dtReturn = null; Console.WriteLine(ex.Message); } }
Informix 中執行多條SQL(Execute Script)