Re: VB6 Change all records in specific table
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sun, 7 Jan 2007 07:46:37 -0500
You need to learn how to use SQL.
The SQL statement for what you're trying to do would be:
UPDATE Links SET [Type] = "R" WHERE [Type] = "T"
Note the inclusion of the square brackets around Type: Type is a reserved
word, and really shouldn't be used for your own purposes. If you cannot (or
will not) rename the field, using the square brackets will lessen the
likelihood of problems.
Unfortunately, I'm not sure how you use a DSN connection to connect to an
Access database with VB6: I've always just used DAO when working with Access
and VB, so I'd instantiate a Database object, and run the SQL:
Dim dbCurr As DAO.Database
Dim strSQL As String
strSQL = "UPDATE Links SET [Type] = 'R' WHERE [Type] = 'T'"
Set dbCurr = OpenDatabase("PathToMDB")
dbCurr.Execute strSQL, dbFailOnError
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Josh" <hype8912@xxxxxxxxx> wrote in message
news:1168152426.165159.85690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am pretty good with VB, but I don't understand how to use databases
with VB yet. I prefer to use VB6 over 2003 or 2005 because I don't have
to worry about the bloated permissions.
I am trying to access an MS Access 97 database called "DB.mdb" with
multiple tables in it. In the "Links" table, field called "Type" I need
to change all the "T"s to "R"s. This field only contains one letter at
all times. There are over 300 thousand records in this table.
I usually do the replacement of the Ts to Rs manually but I would like
to programmatically do this from a single script.
I have a System DSN connection already setup called "DBConn" pointing
to the access database.
The user name is "admin" and the password is "db0102"
How do I setup a connection in VB6 to use the DSN connection already
setup to change all the records in the specific table field? I would to
prefer to see code as thats how I've learned anything so far.
Any books or links would be useful too.
.
- Follow-Ups:
- Re: VB6 Change all records in specific table
- From: Ralph
- Re: VB6 Change all records in specific table
- References:
- VB6 Change all records in specific table
- From: Josh
- VB6 Change all records in specific table
- Prev by Date: VB6 Change all records in specific table
- Next by Date: Re: VB6 Change all records in specific table
- Previous by thread: VB6 Change all records in specific table
- Next by thread: Re: VB6 Change all records in specific table
- Index(es):
Relevant Pages
|