By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

Assign values retrieved from a dataset to variables

P: n/a
Currently I am retrieving values from a dataset and assigning the
values to a textbox. I then assign the value from the textbox to a
variable. I don't need the values in the textbox at all. I'm sure there
is an easier way than I'm doing it. Any suggestions or help would be
appreciated. Below is a snippet of code to show what I'm currently
doing.

string cmdQuestionEdit="SELECT Question_Subject, "+
"Question_Weight, "+
"QuestionType_ID, " +
"Question_Status, "+
"Question_QuestionContent, "+
"Quiz_ID, " +
"SortType_ID, "+
"Quiz_Version, " +
"Quiz_Number, " +
"Question_Version, " +
"Question_Number, " +
"QuestionType_ID " +
"FROM Question " +
"Where '"+txtQuestionID.Text+"' = " +
"Question_ID and '"+txtQuizID.Text+"' " +
"= Quiz_ID ";

sqlConnection1.Open();
SqlDataAdapter daEdit=new SqlDataAdapter(cmdQuestionEdit,
sqlConnection1);
daEdit.Fill(dsMain1,"Question");
DataTable dtEdit = dsMain1.Tables["Question"];

foreach (DataRow questionRow in dtEdit.Rows)
{
txtVersion.Text = questionRow["Question_Version"].ToString
().Trim();
txtNumber.Text = questionRow["Question_Number"].ToString
().Trim();

}//end for

//Edit quiz
//get values fom drop down list
valEditQuizVersion = int.Parse(txtVersion.Text);
valEditQuizNumber = int.Parse(txtNumber.Text);

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"gjtired" <jo****@boystown.org> wrote in news:1108480381.259642.19910
@l41g2000cwc.googlegroups.com:
Currently I am retrieving values from a dataset and assigning the
values to a textbox. I then assign the value from the textbox to a
variable. I don't need the values in the textbox at all. I'm sure there
is an easier way than I'm doing it. Any suggestions or help would be
appreciated. Below is a snippet of code to show what I'm currently
doing.


What is the question? How to do it without the text boxes? To me the questino
is why are you not just reading directly from the datatable?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 16 '05 #2

P: n/a
I'd also add that the original poster can use typed datasets to gain more
'syntactic sugar' and make the code reading the dataset more readable and
intuitive.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn******************@127.0.0.1...
"gjtired" <jo****@boystown.org> wrote in news:1108480381.259642.19910
@l41g2000cwc.googlegroups.com:
Currently I am retrieving values from a dataset and assigning the
values to a textbox. I then assign the value from the textbox to a
variable. I don't need the values in the textbox at all. I'm sure there
is an easier way than I'm doing it. Any suggestions or help would be
appreciated. Below is a snippet of code to show what I'm currently
doing.


What is the question? How to do it without the text boxes? To me the
questino
is why are you not just reading directly from the datatable?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.