public DataSet SearchData(DataModel dm)
{
SqlCommand cmd = new SqlCommand("sp_Grid", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] param ={new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@dept",SqlDbType.VarChar,50),
new SqlParameter("@sal",SqlDbType.Int),
new SqlParameter("@type",SqlDbType.VarChar,50)
};
param[0].Value = dm.Name;
param[1].Value = dm.Dept;
param[2].Value = dm.Sal;
param[3].Value = "Search";
cmd.Parameters.Add(param[0]);
cmd.Parameters.Add(param[1]);
cmd.Parameters.Add(param[2]);
cmd.Parameters.Add(param[3]);
con.Open();
try
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Table1");
return ds;
}
catch (Exception Ex)
{
throw Ex;
}
finally
{
con.Close();
}
}
public int Insert(DataModel dm)
{
try
{
SqlCommand cmd = new SqlCommand("Grid", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] param ={new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@dept",SqlDbType.VarChar,50),
new SqlParameter("@sal",SqlDbType.Int),
new SqlParameter("@type",SqlDbType.VarChar,50)
};
param[0].Value = dm.Name;
param[1].Value = dm.Dept;
param[2].Value = dm.Sal;
param[3].Value = "Select";
cmd.Parameters.Add(param[0]);
cmd.Parameters.Add(param[1]);
cmd.Parameters.Add(param[2]);
cmd.Parameters.Add(param[3]);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
return i;
}
catch (Exception ex)
{
throw ex;
}
}
{
SqlCommand cmd = new SqlCommand("sp_Grid", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] param ={new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@dept",SqlDbType.VarChar,50),
new SqlParameter("@sal",SqlDbType.Int),
new SqlParameter("@type",SqlDbType.VarChar,50)
};
param[0].Value = dm.Name;
param[1].Value = dm.Dept;
param[2].Value = dm.Sal;
param[3].Value = "Search";
cmd.Parameters.Add(param[0]);
cmd.Parameters.Add(param[1]);
cmd.Parameters.Add(param[2]);
cmd.Parameters.Add(param[3]);
con.Open();
try
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Table1");
return ds;
}
catch (Exception Ex)
{
throw Ex;
}
finally
{
con.Close();
}
}
public int Insert(DataModel dm)
{
try
{
SqlCommand cmd = new SqlCommand("Grid", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] param ={new SqlParameter("@name",SqlDbType.VarChar,50),
new SqlParameter("@dept",SqlDbType.VarChar,50),
new SqlParameter("@sal",SqlDbType.Int),
new SqlParameter("@type",SqlDbType.VarChar,50)
};
param[0].Value = dm.Name;
param[1].Value = dm.Dept;
param[2].Value = dm.Sal;
param[3].Value = "Select";
cmd.Parameters.Add(param[0]);
cmd.Parameters.Add(param[1]);
cmd.Parameters.Add(param[2]);
cmd.Parameters.Add(param[3]);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
return i;
}
catch (Exception ex)
{
throw ex;
}
}