Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
How to retrieve the selected item data from database to Gridview using C#.
roy himanshu
Sep 10 2009 8:27 AM
6.3k
Reply
hi,
How to retrieve the selected item data from database to Gridview using C#
.
paste my code below,help me
private
void
dataGridView1_DoubleClick(
object
sender,
EventArgs
e)
{
cn =
new
SqlConnection
(
"data source=server2;database=costing1;user id=sa;password=sa"
);
da2 =
new
SqlDataAdapter
(
"select *from CATABLE001 where column002='@column002'"
, cn);
ds =
new
DataSet
();
da2.MissingSchemaAction =
MissingSchemaAction
.AddWithKey;
da2.Fill(ds,
"CATABLE001"
);
cmd =
new
SqlCommand
();
cmd.Connection = cn;
cmd.CommandType =
CommandType
.StoredProcedure;
int
sno =
int
.Parse(
Interaction
.InputBox(
"Enter ItemCode"
,
"db operations"
,
""
, 50, 50));
DataRow
dr = ds.Tables[
"CATABLE001"
].Rows.Find(sno);
dataGridView1.DataSource = ds.Tables[
"CATABLE001"
];
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
can i add new column in table through gridview?
how to assigning variables from gridview to database table in C#?