943,693 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 1529
  • ASP.NET RSS
Oct 20th, 2008
0

insert into a DATABASE

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
bharatshivram is offline Offline
35 posts
since Mar 2007
Oct 20th, 2008
1

Re: insert into a DATABASE

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();
Reputation Points: 12
Solved Threads: 4
Light Poster
reena12 is offline Offline
32 posts
since Oct 2008
Oct 20th, 2008
0

Re: insert into a DATABASE

thanx a lot.. worked fine..
Reputation Points: 10
Solved Threads: 1
Light Poster
bharatshivram is offline Offline
35 posts
since Mar 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC