Hi,
For Insert/Update/Delete you can use
public bool Insert(string sQry)
{
try
{
con = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(sQry, con);
cmd.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
return false;
}
finally
{
con.Close();
}
}
And for select query you can use below code
public DataTable LoadDataTable(string sQry)
{
DataTable dt = new DataTable();
try
{
con = new SqlConnection(WebConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
SqlDataAdapter sDap = new SqlDataAdapter(sQry, con);
sDap.Fill(dt);
return dt;
}
catch (Exception ex)
{
return null;
}
}
Above code is vary simple and just for start coding with asp.net & sql , but in professional work query fired using stored procedure...