แบ่งออกเป็น 2 แบบ
1. Send Parameter String SQL and Database Name Return DataSet
public DataSet Query_All(String isSQL, String Database)
{
try{
this.objConn.Open();
DataSet ds = new DataSet();
this.objCmd = new SqlCommand(isSQL, objConn);
SqlDataAdapter sadpter = new SqlDataAdapter(this.objCmd);
ds.Clear();
sadpter.Fill(ds, Database);
this.objConn.Close();
return ds;
}
catch (InvalidOperationException XcpInvOp)
{
System.Windows.Forms.MessageBox.Show(XcpInvOp.ToString());
return null;
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
return null;
}
}
_________________________________________________________________
2. Send Parameter Command and Return DataSet
public DataSet Query_All(SqlCommand cmd,String DB)
{
try
{
this.objConn.Open();
DataSet ds = new DataSet();
this.objCmd = cmd;
SqlDataAdapter sadpter = new SqlDataAdapter(this.objCmd);
ds.Clear();
sadpter.Fill(ds, DB);
this.objConn.Close();
return ds;
}
catch (InvalidOperationException XcpInvOp)
{
System.Windows.Forms.MessageBox.Show(XcpInvOp.ToString());
return null;
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
return null;
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น