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

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

commented: thanx a tonne.. +2

thanx a lot.. worked fine..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.