Friday 29 April 2016

Connection with SQL Server Part 7

Insert Data using Connection Class:-

on the submit button click event code for insert data using sql class connection

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Insert : System.Web.UI.Page
{

    Class1 obj = new Class1();


    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string str="insert into Datas(firstname,lastname,mobile) values('"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"')";
        obj.savedata(str);
    }
}

In this coding the Class1 obj = new Class1();
 create new object of that class and we can use that class method , in our case we create two method the calldata(), and the savedata();

The calldata(); method is used to retrieve  data from database and 
  
The savadata(); method is used to execute the query

using the object of that class . 

2 comments:

Part 20 consuming rest api in ionic

in this video, I will show you that how you can consume the rest API. in the previous video we have implemented the asp.net web API projec...