ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Microsoft Related >> ASP.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions (614)
 C Sharp interview questions  C Sharp Interview Questions (721)
 ASP.NET interview questions  ASP.NET Interview Questions (1442)
 VB.NET interview questions  VB.NET Interview Questions (150)
 COM+ interview questions  COM+ Interview Questions (41)
 ADO.NET interview questions  ADO.NET Interview Questions (198)
 IIS interview questions  IIS Interview Questions (86)
 MTS interview questions  MTS Interview Questions (5)
 Crystal Reports interview questions  Crystal Reports Interview Questions (62)
 BizTalk interview questions  BizTalk Interview Questions (33)
 Dot Net interview questions  Dot Net Interview Questions (861)
 Exchange Server interview questions  Exchange Server Interview Questions (103)
 SharePoint interview questions  SharePoint Interview Questions (25)
 WCF interview questions  WCF Interview Questions (8)
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions (193)
Question
How to Insert a TextBox value in to Sql database using C#
coding?
 Question Submitted By :: Mail2ssuresh
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 1
insert into emp(empname) values('"+textbox1.value+"')


If you use html cocntrol textbox1.Value
or
If you use Aso cocntrol textbox1.Text
 
Is This Answer Correct ?    183 Yes 80 No
Chandra Shaker
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 2
insert into emp(empname) values('"+textbox1.Text+"'); 
Is This Answer Correct ?    156 Yes 59 No
Sona
 
 
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 3
Syntax:
INSERT INTO table name(column name,column name,column
name)values(values,values,values);
Example:
INSERT INTO
employee(Name,emp_id,designation)values('"+textbox1.text+"',"+textbox2.text+",'"+textbox3.text+"');


..................if u use Html control we must use
textbox1.value ..if u use asp.net controls we have to use
textbox1.text........
 
Is This Answer Correct ?    155 Yes 54 No
V.vijayakumar
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 4
in asp.net webform,

first assign namespace like using system.data.sqlclient;

insert coding

sqlcommand cmd = new sqlcommand("insert into address values
('"+ textbox1.text +"', "+ textbox2.text +")",
connectionstring);

note:
 
Is This Answer Correct ?    141 Yes 55 No
Premkumar.m
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 5
sqlcommand cmd = new sqlcommand("insert into address values
(@textbox1.text,@textbox2.text)",connectionstring);
 
Is This Answer Correct ?    61 Yes 37 No
Pksutha
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 6
sqlcommand cmd = new sqlcommand("insert into address values
('"+ textbox1.text +"', "+ textbox2.text +")",
connectionstring);
 
Is This Answer Correct ?    64 Yes 39 No
Suthasyed
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 7
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 ?    110 Yes 33 No
Digital
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 8
first assign namespace like using system.data.sqlclient;

SqlCommand cmd = new SqlCommand("insert into emp
(EmpName,EmployeeCode,Designation,Location)values('" +
TextBox1.Text + "','" + TextBox2.Text + "','" +
TextBox3.Text + "','" + TextBox4.Text + "')");
 
Is This Answer Correct ?    48 Yes 33 No
Pranitha
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 9
SqlConnection conn = new SqlConnection(strCon);
SqlCommand CmdSql = new SqlCommand("INSERT INTO Customers
(Firstname,Lastname,Address)Values('" + textbox1.Text
+ "', '"+textbox2.Test+"', '"+textbox3.Text+"')", conn);
CmdSql.ExecuteNonQuery();


\\If u use Html control we must use
textbox1.value
\\If u use asp.net controls we have to use
textbox1.text
 
Is This Answer Correct ?    47 Yes 23 No
Ramachandraprabu
 
  Re: How to Insert a TextBox value in to Sql database using C# coding?
Answer
# 10
SqlConnection con = new SqlConnection();
con.ConnectionString = "connection string(path)";
try
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into emp_detail values(' " + tb1.Text + " ',' " + tb2.Text + " ',' " + tb3.Text + " ')", con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
 
Is This Answer Correct ?    61 Yes 26 No
Jegan
 

 
 
 
Other ASP.NET Interview Questions
 
  Question Asked @ Answers
 
can any one explain about 3-tier architecture and how to deploy 3 layers of 3-tier architecture in 3 different servers.plz send me .net code Wipro 1
Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one   1
What is the difference between application object and session object? IBS 4
web user and custom conrols   1
Can One website be made using two different languages like c#,vb.net etc...... ABC 4
How can we Maintain more than on config file in one .Net web application and how? USi 1
how many databases and tables are uses in one project?   2
I am using a range validator and want to use dd mm yyyy format for accepting dates. I get a fairly generic "can't do that" type exception when I use this format for setting the minValue or maxValue properties for the range validator. How can I force it to accept my format? FutureTech 1
How Can we use multiple forms in single asp.net application? Polaris 3
Is object a value type or referenced type?   2
Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one?   1
which method marks a config file section for encryption?   1
 
For more ASP.NET Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com