![]() |
|||
Simple Insert data using(DATA SET) ds and dt
By: rekha singh | 29 Apr 2010 11:36 am
Save button event
protected void btn_save_Click(object sender, EventArgs e)
{
first f = new first();
f.id = Convert.ToInt32(TextBox1.Text);
f.name = TextBox2.Text;
f.course = TextBox3.Text;
f.fee = Convert.ToInt32(TextBox4.Text);
datac c=new datac();
c.insertmain(f);
Label1.Text = "record inserted";
}
Variable class
public class first
{
public int id{get;set;}
public string name { get; set; }
public string course { get; set; }
public int fee { get; set; }
}
Data class
public void insertmain(first f)
{
string query = "Insert into student values(" + f.id + ",'" + f.name + "','" + f.course + "'," + f.fee + ")";
string constring = "Data Source= SHYAM-6E8C5C74B\\SQLEXPRESS ;initial catalog=college; integrated security=True "
SqlConnection cn = new SqlConnection(constring);
SqlDataAdapter da = new SqlDataAdapter(query,cn);
DataSet ds = new DataSet();
da.Fill(ds);
}
|
