Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
402 views
in Technique[技术] by (71.8m points)

c# - Get data from datatable into a string in asp.net

I use a SQL query and store the result into a datatable and now I want to write a specific cell data in to a string or char.

Below is the code I want to get the data from row[0] column[1]

da = new SqlDataAdapter("SELECT * FROM SeatsDetails WHERE ServiceNo='"+srno+"' AND Date='"+date+"'", con);
dt = new DataTable();
da.Fill(dt);
String t1 = (String) dt.Rows[0][1];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had got it using, Thanks fo the effort.

String t1 = dt.Rows[0][1].ToString();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...