0

hi i am using visual studio 2008 express edition. i have created a database in sql ( add new item > sql database). the db has 2 fields uname and upwd.
have also created a web page in asp.net that has 2 text boxes (textbox1,textbox2) and a command button (cmdbutton1). i want to insert the values entered by the user into the database that ive created on the click event of the button..Please provide me the code to do thye above mentioned..

Regards,
Bharat Shivram

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by bharatshivram
1

using System;
using System.Data;
using System.Data.SqlClient;

string sConnectionString = "Integrated Security=SSPI;Initial Catalog=;Data Source=localhost;";

SqlConnection objConn = new SqlConnection(sConnectionString);
objConn.Open();

string sSQL = "INSERT INTO Users (uname,upwd) VALUES ('" + textbox1.Text + "','" + textbox2.Text + "')";
SqlCommand objCmd = new SqlCommand(sSQL,objConn);
objCmd.ExecuteNonQuery();

Votes + Comments
thanx a tonne..
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.