Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Update errors from ADO update

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-03-03 : 07:32:12
Steve writes "Hi

A recent project I have been working has made great use of grids and ADO recordsets filled with data from stored procedures. The records in these grids are often updated, normally just one field from a three table select statement in the proc.

On a couple of occassions the update has not worked and returns an "Update Error" message which is very unhelpful. I usually start looking at the VB code to find the problem but usually find that it lies with one of the triggers of one of the tables in the select query.

If I perform the update against a record in query analyzer I would recieve a meaningful error message. What I don't understand is why the meaningful message is not passed back through ADO into my application. How are error messages returned from SQL Server to an OLEDB/ODBC connection such as an ADO connection object."

Max_rv
Starting Member

3 Posts

Posted - 2003-03-03 : 08:51:18
Maybe adoConn.Errors collection?

Try to process ADO connectoin events, this is code from my project:

Private WithEvents adoConn As ADODB.Connection

...............

Private Sub Con_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As ADODB.Connection)
Dim tmpPath As String
If adStatus <> adStatusErrorsOccurred Then Exit Sub
tmpPath = "Errors/" & Date & "/" & Time
frmPreferences.AddKey tmpPath, "Description", pError.Description
frmPreferences.AddKey tmpPath, "Number", pError.Number
frmPreferences.AddKey tmpPath, "SqlState", pError.SQLState
frmPreferences.AddKey tmpPath, "Source", pError.Source
If Not pCommand Is Nothing Then
frmPreferences.AddKey tmpPath, "Command", pCommand.CommandText
End If
frmPreferences.SaveIniFile
End Sub

Private Sub Con_InfoMessage(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
................
End Sub




PS. Sorry for my bad english, my navite language is T-SQL


Go to Top of Page
   

- Advertisement -