public DataSet GetDataSet(string sconn, string cmd)
{
try
{
System.Data.DataSet ds = new System.Data.DataSet();
using (SqlConnection sqlConn = new SqlConnection(sconn))
{
sqlConn.Open();
SqlCommand sqlComm = new SqlCommand();
sqlComm.Connection = sqlConn;
sqlComm.CommandTimeout = 3000;
sqlComm.CommandText = cmd;
SqlDataAdapter adapter = new SqlDataAdapter(sqlComm);
adapter.Fill(ds,"temp");
return ds;
}
}
catch (SqlException e)
{
return null;
}
}
public DataTable GetDataTable(string sconn, string cmd)
{
try
{
DataTable dt = new DataTable();
using (SqlConnection sqlConn = new SqlConnection(sconn))
{
sqlConn.Open();
SqlCommand sqlComm = new SqlCommand();
sqlComm.Connection = sqlConn;
sqlComm.CommandTimeout = 3000;
sqlComm.CommandText = cmd;
SqlDataAdapter adapter = new SqlDataAdapter(sqlComm);
adapter.Fill(dt);
return dt;
}
}
catch (SqlException e)
{
return null;
}
}
public string GetScalar(string sconn, string cmd)
{
try
{
object obj;
using (SqlConnection sqlConn = new SqlConnection(sconn))
{
sqlConn.Open();
SqlCommand sqlComm = new SqlCommand();
sqlComm.Connection = sqlConn;
sqlComm.CommandTimeout = 3000;
sqlComm.CommandText = cmd;
obj = sqlComm.ExecuteScalar();
if (obj == null)
obj = "";
return obj.ToString();
}
}
catch (SqlException e)
{
return "";
}
}