本文整理匯總了C#中MySql.Data.MySqlClient.MySqlDataAdapter.Close方法的典型用法代碼示例。如果您正苦於以下問題:C# MySqlDataAdapter.Close方法的具體用法?C# MySqlDataAdapter.Close怎麽用?C# MySqlDataAdapter.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MySql.Data.MySqlClient.MySqlDataAdapter
的用法示例。
在下文中一共展示了MySqlDataAdapter.Close方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: getAllEmployee
public List<Employee> getAllEmployee(Employee emp, String sortColumn,Boolean asc,Boolean exactFilter)
{
List<Employee> result = new List<Employee>();
MySqlTransaction tr = null;
MySqlDataAdapter rdr = null;
String sql = "SELECT * FROM EMPLOYEE WHERE 1=1 ";
Dictionary<String, String> paramDic = new Dictionary<String, String>();
if(emp != null)
{
String strFilter = emp.getStrFilter();
if (!String.IsNullOrWhiteSpace(strFilter))
{
if (exactFilter)
{
sql += " AND E_NAME = @NAME ";
paramDic.Add("@NAME",strFilter);
}
else
{
sql += " AND E_NAME LIKE '% @NAME %' ";
paramDic.Add("@NAME",strFilter);
}
}
}
if(sortColumn != null)
{
String sort = (asc == true? "ASC":"DSC");
sql += " ORDER BY @COLUMN @SORT ";
paramDic.Add("@COLUMN",sortColumn);
paramDic.Add("@SORT", sort);
}
try
{
conn = getConnection();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.Transaction = tr;
cmd.CommandText = sql;
foreach (KeyValuePair<String, String> pair in paramDic)
{
cmd.Parameters.AddWithValue(pair.Key, pair.Value);
}
rdr = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
rdr.Fill(dt);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
}
finally
{
if(rdr != null)
{
rdr.Close();
}
DBUtil.CloseConnection(conn);
}
return result;
}