1.
pSqlCommand主要是要執行的SQL語句。
2. pFillSchema主要是判斷是否填入撈出數據的Schema,填入到DataTable中。
3. Schema包括鍵值/限制條件等相關資訊。
4. 由於撈取一次Schema會多一次資料庫存取的連線,所以視情況確認是否做表結構的取得,
比如需求是只做資料的呈現時,就沒必要做這動作了。
public DataTable executeQuerySqlCommand(string pSqlCommand, bool pFillSchema)
{
DataTable lResult = new DataTable();
SqlDataAdapter lSqlDataAdapter = new SqlDataAdapter(pSqlCommand, this.ConnectionString);
if (pFillSchema)
lSqlDataAdapter.FillSchema(lResult, SchemaType.Source);
lSqlDataAdapter.Fill(lResult);
return lResult;
}
2. pFillSchema主要是判斷是否填入撈出數據的Schema,填入到DataTable中。
3. Schema包括鍵值/限制條件等相關資訊。
4. 由於撈取一次Schema會多一次資料庫存取的連線,所以視情況確認是否做表結構的取得,
比如需求是只做資料的呈現時,就沒必要做這動作了。
public DataTable executeQuerySqlCommand(string pSqlCommand, bool pFillSchema)
{
DataTable lResult = new DataTable();
SqlDataAdapter lSqlDataAdapter = new SqlDataAdapter(pSqlCommand, this.ConnectionString);
if (pFillSchema)
lSqlDataAdapter.FillSchema(lResult, SchemaType.Source);
lSqlDataAdapter.Fill(lResult);
return lResult;
}