insert into a DATABASE

Thread Solved

Join Date: Mar 2007
Posts: 35
Reputation: bharatshivram is an unknown quantity at this point 
Solved Threads: 1
bharatshivram bharatshivram is offline Offline
Light Poster

insert into a DATABASE

 
0
  #1
Oct 20th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 32
Reputation: reena12 is an unknown quantity at this point 
Solved Threads: 4
reena12 reena12 is offline Offline
Light Poster

Re: insert into a DATABASE

 
1
  #2
Oct 20th, 2008
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();
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 35
Reputation: bharatshivram is an unknown quantity at this point 
Solved Threads: 1
bharatshivram bharatshivram is offline Offline
Light Poster

Re: insert into a DATABASE

 
0
  #3
Oct 20th, 2008
thanx a lot.. worked fine..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 934 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC