Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write values in database

Status
Not open for further replies.

makisbest

Technical User
Mar 3, 2005
125
GR
Hi all

I create a table in my SQL 2000 Database, with the name "choose". I insert 2 columns value1 as integer and value2 as string.

How I can write values in database choose and how I can update them?

I want to do it in command, and not with designers/dataenvironment

Thank you
 
There are several ways but, assuming that you are using DAO
Code:
CurrentDB.Execute _
  "INSERT INTO Choose (Value1, Value2) " & _
  " VALUES( 1, 'SomeString' ) "
Will insert one record with Value1 = 1 and Value2 = "SomeString".

To update
Code:
CurrentDB.Execute _
  "UPDATE Choose "
  " SET Value1 = 5, Value2 = 'DifferentString' " & _
  " WHERE Value1 = 1 "
Changes the field values on the record inserted by the above INSERT statement.
 
Like this
Code:
Dim CurrentDB As DAO.Database
Set CurrentDB = DAO.DBEngine(0).Opendatabase ("C:\...\myDB.mdb")
You will need a reference to Microsoft DAO 3.x Object Library
 
makisbest -
Take a look at:

This is another URL for connectionstrings.com (which doesn't seem to work for me anymore)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top