This is for insert :
For retrieving You need to put some Effort try to find out by yourself
SqlConnection Con;
SqlCommand Cmd;
SqlDataReader dr;
public string fn_insertCategoryDetails(string strCategoryName)
{
try
{
Con = new SqlConnection(ConfigurationManager.ConnectionStrings["yoConnectionString"].ConnectionString);
Con.Open();
Cmd = new SqlCommand("INSERT INTO InterviewCategories(Category)Values(@name)", Con);
Cmd.Parameters.AddWithValue("@name", strCategoryName);
if (Cmd.ExecuteNonQuery() > 0)
{
return "SUCCESS : Record has been inserted";
}
else
{
return "ERROR : SQL Exception";
}
}
catch (Exception ex)
{
return "ERROR : " + ex.Message;
}
finally
{
if (Con != null)
{
Con.Close();
}
}
}
Read This Link [
^]