Friday, 4 May 2012

0 Sql Connection with ASP.NET (using C#)

Jaskumarblogspot.com


using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;


public partial class Default2 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=Server Name;Initial Catalog=Database name;Integrated Security=True");


    protected void btnsubmit_Click(object sender, EventArgs e)
    {
     
   

            SqlCommand myCommand = new SqlCommand("INSERT INTO tbluserregistration (Col1, Col2, Col3) VALUES  ('" +  textbox1.Text  + "','" +  textbox2.Text  + "','" +  textbox3.Text  + "')", con);


            myCommand.Connection.Open();

            myCommand.ExecuteNonQuery();
            con.Close();

            con.Open();
   


        }
 

 
}




0 comments:

Post a Comment

 

Coding Authority Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates