Article ID: 120763
Article Last Modified on 11/7/2003
If Err = 3146 then
MsgBox Error$
End If
create procedure my_error @custname varchar(18) = null
as
if @custname is null
begin
raiserror 50001 'You Must Enter a Field Name! (#50001)'
end
else
begin
select * from TempTbl
where TempTbl.Last_Name = @custname
end
Sub Command1_Click ()
Const DB_SQLPassThrough = 64 ' Set the passthrough constant.
Dim db As database ' Dimension the local variables.
Dim ds As dynaset
Dim conn As String
Dim sql As String
On Error GoTo Trap ' Set up the error trap.
' Append the SQL Server database:
conn = "odbc;dsn=texas;database=playpen;Username=<username>;PWD=<strong password>;"
Set db = OpenDatabase("", False, False, conn)
' Run the stored procedure:
sql = "my_error"
Set ds = db.CreateDynaset(sql, DB_SQLPassThrough)
' Print the returned record (never get here because of the error).
For i = 0 To ds.Fields.Count - 1
Print ds(i)
Next i
Exit Sub
Trap:
If Err = 3146 Then ' ODBC call failed.
MsgBox Error$
Else
MsgBox "Error:" & Err & "-" & Error$
End If
On Error GoTo 0
Exit Sub
End Sub
Additional query words: 3.00
Keywords: KB120763