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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it Possible in VB to get return code after "Update" ? 1

Status
Not open for further replies.

IrinaK

Programmer
May 21, 2001
33
0
0
US
Hi!

I need to know if the table was updated.

Any suggestions?

Thank you.

 
Do you mean the "Update" method of a recordset? If so then, if no error was raised by the rs.Update command, the record was updated.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Yes I meant "Update" method of a record set.
I have situations when we don't get any error massage, but the table wasn't updated.

Thanks.
 
I am not sure if there is a differnce, but I have
different update:
cn.Execute "UPDATE..."
Thanks.
 
If you are using ADO to execute the Update command, you can pass the execute function a second parameter. This second parameter would indicate the number of records affected by the update statement.

Ex.

Dim DB as ADODB.Connection
Dim iRecordsAffected As Long

Set DB = CreateObject("ADODB.Connection")
DB.ConnectionString = "YourConnectionString"
Call DB.Open

Call DB.Execute("Your Update Query", iRecordsAffected)
Msgbox "Records Affected = " & CStr(iRecordsAffected)


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You're welcome. I'm glad it helped.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You can also just use the .RecordsAffected attribute of the connection after you execute the statement:
Code:
Msgbox "Records Affected = " & CStr(DB.RecordsAffected)


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top