Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to Insert a TextBox value in to Sql database using C#
coding?

Answer Posted / digital

SqlCommand CmdSql = new SqlCommand("INSERT INTO
Customers(FirstName,Surname,Address,City,Postcode,PhoneNumber)
Values
(@FirstName,@Surname,@Address,@City,@Postcode,@PhoneNumber)", conn);
conn.Open();
CmdSql.Parameters.AddWithValue("@FirstName", FirstName);
CmdSql.Parameters.AddWithValue("@Surname", Surname);
CmdSql.Parameters.AddWithValue("@Address", Address);
CmdSql.Parameters.AddWithValue("@City", City);
CmdSql.Parameters.AddWithValue("@Postcode", Postcode);
CmdSql.Parameters.AddWithValue("@PhoneNumber",
PhoneNumber);
CmdSql.ExecuteNonQuery();
conn.Close();

//all @values are names of the variables the text value is
stored as (you could also enter txtFirstName.Text etc.)
//conn = connection name (which should be declared before
the page_load

Is This Answer Correct ?    113 Yes 35 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between overriding and overloading?

1198


What does a switch do?

925


What is the difference between an htmlinputcheckbox control and an htmlinputradiobutton control?

1071


What is the recommended approach for asp.net mvc to globally intercept exceptions? What other functionality can be implemented with the approach? : Asp.Net MVC

924


Is post back in asp.net?

932


What is state management in asp.net with example?

910


What is the difference between the response.write() and response.output.write() methods?

972


Can anyone please tell me that the question posted on this website are Sufficient for the interview with 2+ year experience in .net

1986


What is caching in asp.net?

978


What’s the use of “GLOBAL.ASAX” file?

1046


Which adapter should you use, if you want to get the data from an access database?

949


Briefly describe the role of global.asax?

945


What is the difference between dynamic SGA and static SGA?

1096


What is the difference between equals() and == in c#?

965


How does asp.net work?

927