Insert data in SQL Database using c#.Net

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

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           
SqlConnection cnn = new SqlConnection(@"Data Source=localhost\SQLExpress;Initial Catalog=awais;Integrated Security=True;Integrated Security=True ");
cnn.Open();
           
string query="insert into logout(name,password) values('" + TextBox1.Text + "','" + TextBox2.Text + "' )";
SqlCommand cmd=new SqlCommand(query,cnn);
cmd.ExecuteNonQuery();

Response.Write("Saving is done!");


           
        }
         
        }
    }
}

No comments

Powered by Blogger.