-
Want to pass a variable
Here is what I am trying to do. I am working on a simple vb.net quiz program from my work, using an Access database with two tables. Each table will be a different set of quiz questions, with the same basic structure.
In my form, I have a textbox that I want to fill with the text in the question column of the table. I am not using SQL queries. Here is the way the line is written:
txtquestion.text=dsquiz12.quiz1.item(me.bindingcontext(dsquiz12, "quiz1").position).question
I would like to replace quiz1 with a variable, to allow me to specify which table in the database to use. Is this possible? I've tried a few things, such as creating a string variable with a value of the name of the table. However, I cannot seem to put this in the above statement.
I am something of a beginner for doing this, so I feel I am probably overlooking the solution.
Thanks,
Jason A.
[edit]
Noticed I dropped a paratheses after position.
Last edited by json.a.ash; 01-06-2005 at 03:25 PM.
-
Try something like this:
Dim sQuiz As String = "quiz1"
txtQuestion.Text=dsquiz12.Item(sQuiz).Item(Me.BindingContext(dsquiz12, "quiz1").Position.Question
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Originally posted by Phil Weber
Try something like this:
Dim sQuiz As String = "quiz1"
txtQuestion.Text=dsquiz12.Item(sQuiz).Item(Me.BindingContext(dsquiz12, "quiz1").Position.Question
Gave this a try, and still have a problem. The system reports that "item is not a member of dsquiz1"
Thanks for the suggestion though....
Maybe I should also clarify a bit more:
dsquiz1 is the dataset (second one I created, which is why the dsquiz12, the first only had one of the tables)
quiz1 is the name of the table.
Question is a column in the table.
-
Then maybe this?
txtQuestion.Text = dsquiz12.Tables(sQuiz).Item(Me.BindingContext(dsquiz12, "quiz1").Position.Question
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks