|
INTERVIEW QUESTIONS
MICROSOFT
DATAGRID
DETAILS
Question: How to insert value in the combo box cell of dataGridView using insert query in C#?How to handle the data error event?
Answer: we can insert details by two types 1.commandtype=command.Text 2.commandType=Command.Storedprocedure
mostly we use stored procedure. so we have to create insert query in database.
create database emp create table empdetails ( empid int, name varchar(20), salary money )
create proc insertdata (@empid int,@name varchar (20),@salary money) AS insert into empdetails values empid=@empid,name=@name,salary=@salary exec insertdata
protected void button_clik event..... { sqlconnection con=new sqlconnection("database=emp";server=.;integrated security="true");
sqlcommand cmd= new sqlcommand(); cmd.commandtext="insertdata"; cmd.commandtype=commandtype.storedprocedure; cmd.connection=con;
con.open(); cmd.parameters.add("@empid",sqlDbtype.int).value=txtempid.text;
cmd.parameters.add("@name",sqlDbtype.varchar).value=txtname.text;
cmd.parameters.add("@salary",sqlDbtype.money).value=txtsalary.text; cmd.executenonquery(); con.close(); } }
|
|
|
Category |
DataGrid Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9090 users |
Added on |
12/28/2013 |
Views |
66381 |
Rate it! |
|
|
Question:
How to insert value in the combo box cell of dataGridView using insert query in C#?How to handle the data error event?
Answer:
we can insert details by two types 1.commandtype=command.Text 2.commandType=Command.Storedprocedure
mostly we use stored procedure. so we have to create insert query in database.
create database emp create table empdetails ( empid int, name varchar(20), salary money )
create proc insertdata (@empid int,@name varchar (20),@salary money) AS insert into empdetails values empid=@empid,name=@name,salary=@salary exec insertdata
protected void button_clik event..... { sqlconnection con=new sqlconnection("database=emp";server=.;integrated security="true");
sqlcommand cmd= new sqlcommand(); cmd.commandtext="insertdata"; cmd.commandtype=commandtype.storedprocedure; cmd.connection=con;
con.open(); cmd.parameters.add("@empid",sqlDbtype.int).value=txtempid.text;
cmd.parameters.add("@name",sqlDbtype.varchar).value=txtname.text;
cmd.parameters.add("@salary",sqlDbtype.money).value=txtsalary.text; cmd.executenonquery(); con.close(); } } Source: CoolInterview.com
Answered by: sachin kumar | Date: 6/23/2010
| Contact sachin kumar
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the Datagird ?
|
View Answer
|
|
In DataGrid, is it possible to add rows one by one at runtime. That means after entering data in one row next row will be added.
|
View Answer
|
|
How to add DateTime Control in ormal DataGrid Server Control
|
View Answer
|
|
How to refresh the data in datagrid automatically
|
View Answer
|
|
How to sort the data in Datagrid ? when we use DataBound event of Datagrid, I want to display te data using controls.... For an example, If i click a button, which is outside of the datagrid, entire data should be shown. 1st column in TextBoxs. second column in Drop down List Boxs.. How to bind the data in Dropdownlist,which is in DataGrid at run time? Row1 Row2 Row3 Row4 ----------------- This is the record in datagrid...
When we click button (Bottom of the DataGrid), This Record should be shown... Row1 in TextBox,,, Row2 in TextBox, Row3 in DropDownlistbox, Row4 in TextBox... How to do this one? Which event we should use?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All DataGrid Interview Questions & Answers - Exam Mode /
Learning Mode
|