DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login
SQL
IT Tags

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);
 
 
        }
 

Comments

No Comments Posted for this Article.

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move