If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Is there someone can help? (Problem with updating DB2 records with VBA)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-12-03, 13:46
wanglei63 wanglei63 is offline
Registered User
 
Join Date: Dec 2003
Posts: 1
Red face Is there someone can help? (Problem with updating DB2 records with VBA)

Is there someone can help?

I have Db2 v3r2 on AS4000 here. The AS400 system is named Zeus. I tried to update a db2 record with VBA.

When I use ODBC and DAO, I can retrieve the record and obtain the field value for Name field
but I cannot update the value. When .Update line is excuted, program returns an error msg
"ODBC failed."
I have DONOID as primary key. I tried both Numberic (0 decimal) and Alphabetic Type for DONOID.
I cannot make it work.
Here is the code I used to open the recordset:
Set ODBCWorkspace = CreateWorkspace("ODBCDirect", "A", "", dbUseODBC)
Set MyConnection = ODBCWorkspace.OpenConnection("Zeus DSN", dbDriverNoPrompt, False)
sqlstring = "Select DONO2.* FROM QS36F.DONO2"
Set DonoTable = MyConnection.OpenRecordset(sqlstring, dbOpenDynaset, 0, dbOptimistic)

I tried to use a pass query to update the table. Query such as
"INSERT INTO QS36F.DONO2(DONOID, DONOTYPE, NAME) VALUES('4', '2', 'Name FOUR')"
"DELETE * FROM QS36F.DONO2 WHERE (DONO2.DONOID='1')"
succeeded. However queries such as
"Update QS36F.DONO Set DONO.Name = 'New Name' WHERE (DONO.DONOID = '1')"
failed. I wonder what is special for an update query for DB2 on AS400.

Last edited by wanglei63; 12-17-03 at 10:27.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On