Updating recordsets in VB6
Another question for you...
I am creating a program that, as a part of it, will display & allow a user to update, the scores for each game in an NFL season. I have 32 tables, 1 for each NFL team, following the naming convention of "tbl_Sch_Buf" or "tbl_Sch_GB"
When a user inputs the score for GB into a text box, and clicks on "update scores", I want to write that score to the GB table. Here is where I am getting hung up..
I have a Data Environment with 41 command objects, 32 of which are the tables for each team. The name of the Data Environment is, aptly, DataEnv1. When trying to write to the table, this is what I have been doing...
strUpdate = "Update DataEnv1.rstbl" & strHomeAbbr & " SET Score = " & txtScoreHome.Text
When I do this, I get an error stating that VB cannot find the database "DataEnv1.mdb"
I am really stuck on this and cannot move forward with this part of the program until I can figure out where I am going wrong. Much appreciated if anyone can help me out...
Hi, Scott: In most cases, you'd create separate Commands for querying, inserting, updating and deleting from each table. I don't know of any way to get the name of the underlying table from a Command object. You should be able to do something like this:
strUpdate = "UPDATE tbl_Sch_" & strHomeAbbr & " SET Score = " & txtScoreHome.Text
UPDATE updates an existing record, so you'll probably need to add a WHERE clause to select a specific one.
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
It appears that you were qualifying the table name with "DataEnv1", which was not good. Also, if I remember right, you are going to need to specify a "Where" clause on your SQL statement.
How many records do you have per table, if you have more then one you need to use the WHERE clause to point to the specific record that needs to be updated in the database.
On a side note, in database development, you wouldnt have seperate tables for things that can be grouped together into one table. What I mean is, it would be better to have a single table with the team names store in the table with a unique id for each team, then you could refer to each team by its unique id. Im not suggesting you change it, but its something to consider in future developments when working with databases.
By smithg22 in forum VB Classic
Last Post: 04-12-2005, 06:23 PM
By Bert R. in forum VB Classic
Last Post: 03-19-2002, 08:32 AM
By Jade29 in forum VB Classic
Last Post: 01-12-2002, 10:12 PM
By Jennifer in forum VB Classic
Last Post: 11-19-2001, 03:16 AM
By venkatesh in forum ASP.NET
Last Post: 01-17-2001, 04:10 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center