PC Review


Reply
Thread Tools Rate Thread

Assign values retrieved from a dataset to variables

 
 
gjtired
Guest
Posts: n/a
 
      15th Feb 2005
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);

 
Reply With Quote
 
 
 
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      15th Feb 2005
"gjtired" <(E-Mail Removed)> 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/
 
Reply With Quote
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      15th Feb 2005
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" <(E-Mail Removed)> wrote in message
news:Xns95FE6A27BD323cpub@127.0.0.1...
> "gjtired" <(E-Mail Removed)> 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/


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Access form to assign values of variables in an Excel VBAprogram rjagathe Microsoft Excel Programming 0 10th Apr 2010 02:30 PM
Using Wend to assign form object values to variables. =?Utf-8?B?SnVzdGlu?= Microsoft Access Form Coding 5 16th Oct 2006 04:44 AM
Get field values from a query and assign to array variables larpup@pacbell.net Microsoft Access 4 12th Apr 2006 04:31 PM
Assign Property Values via String Variables? Joe Cool Microsoft VB .NET 1 12th Feb 2006 03:27 AM
How can I assign values to a group of variables in an iteration? M Shafaat Microsoft C# .NET 2 17th Apr 2005 08:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:55 PM.