Object variable or With block variable not set (Trapping SQL errors)

Object variable or With block variable not set (Trapping SQL errors)

Post by Brad M » Wed, 07 Aug 2002 06:28:35



Hi everyone,

I'm trying to trap errors in VB6 (SQL2000 errors) and I've checked the ADO
errors collection.  I get back native errors, so I plug these into my select
case statements.  However, there's a little more to it than I thought.
Here's my statement:

ErrorHandler:
Select Case Err.Number
    Case 18456
        MsgBox "Invalid Login.  Please try again.", vbOKOnly +
vbExclamation, "Error"
    Case 17142
        MsgBox "No new logins are being accepted.  Please try again later.",
vbOKOnly + vbExclamation, "Error"
    Case 17
        MsgBox "Unable to connect to system.  Please try again later.",
vbOKOnly + vbCritical, "Error"
End Select

Anyone see anything wrong?  The error I'm receiving is: Object variable or
With block variable not set.

Any help would be great.  Thanks.

Brad

 
 
 

Object variable or With block variable not set (Trapping SQL errors)

Post by Narayana Vyas Kondredd » Wed, 07 Aug 2002 07:06:14


This seem alright. Could you step through the code in debug mode and see
which exact line is raising this error? I doubt its happening somewhere
else.

Either case, it is a front-end error and has nothing to do with SQL Server
as such.
--
HTH,
Vyas, MVP (SQL Server)

http://vyaskn.tripod.com/


Hi everyone,

I'm trying to trap errors in VB6 (SQL2000 errors) and I've checked the ADO
errors collection.  I get back native errors, so I plug these into my select
case statements.  However, there's a little more to it than I thought.
Here's my statement:

ErrorHandler:
Select Case Err.Number
    Case 18456
        MsgBox "Invalid Login.  Please try again.", vbOKOnly +
vbExclamation, "Error"
    Case 17142
        MsgBox "No new logins are being accepted.  Please try again later.",
vbOKOnly + vbExclamation, "Error"
    Case 17
        MsgBox "Unable to connect to system.  Please try again later.",
vbOKOnly + vbCritical, "Error"
End Select

Anyone see anything wrong?  The error I'm receiving is: Object variable or
With block variable not set.

Any help would be great.  Thanks.

Brad

 
 
 

Object variable or With block variable not set (Trapping SQL errors)

Post by Brad M » Wed, 07 Aug 2002 07:22:06


It is highlighting the Select Case Err.Number line.  Sorry about the
inappropriate area, I thought it may have had something to do with SQL.

Thanks
Brad



> This seem alright. Could you step through the code in debug mode and see
> which exact line is raising this error? I doubt its happening somewhere
> else.

> Either case, it is a front-end error and has nothing to do with SQL Server
> as such.
> --
> HTH,
> Vyas, MVP (SQL Server)

> http://vyaskn.tripod.com/



> Hi everyone,

> I'm trying to trap errors in VB6 (SQL2000 errors) and I've checked the ADO
> errors collection.  I get back native errors, so I plug these into my
select
> case statements.  However, there's a little more to it than I thought.
> Here's my statement:

> ErrorHandler:
> Select Case Err.Number
>     Case 18456
>         MsgBox "Invalid Login.  Please try again.", vbOKOnly +
> vbExclamation, "Error"
>     Case 17142
>         MsgBox "No new logins are being accepted.  Please try again
later.",
> vbOKOnly + vbExclamation, "Error"
>     Case 17
>         MsgBox "Unable to connect to system.  Please try again later.",
> vbOKOnly + vbCritical, "Error"
> End Select

> Anyone see anything wrong?  The error I'm receiving is: Object variable or
> With block variable not set.

> Any help would be great.  Thanks.

> Brad

 
 
 

Object variable or With block variable not set (Trapping SQL errors)

Post by oj » Wed, 07 Aug 2002 07:35:43


There probably isn't really an error other than the fact that you forget to
'exit/end' the sub/function after processing/calling a method?

e.g.

on error goto ErrorHandler
set rs = sqlcnt.execute "select abc from tb"

' Exit Sub    '--If this line is not there the ErrorHandler section will be
stepped into.

ErrorHandler:
debug.print "It continues to this line eventhough there is no error"

--
-oj
Rac v2.1 Public Beta is RELEASED.
http://www.rac4sql.net


Quote:> It is highlighting the Select Case Err.Number line.  Sorry about the
> inappropriate area, I thought it may have had something to do with SQL.

> Thanks
> Brad

 
 
 

Object variable or With block variable not set (Trapping SQL errors)

Post by Brad M » Wed, 07 Aug 2002 10:09:25


Nope oj,

The exit sub on my login routine is in fact in place.  If you need more code
just let me know.

Thanks
Brad


> There probably isn't really an error other than the fact that you forget
to
> 'exit/end' the sub/function after processing/calling a method?

> e.g.

> on error goto ErrorHandler
> set rs = sqlcnt.execute "select abc from tb"

> ' Exit Sub    '--If this line is not there the ErrorHandler section will
be
> stepped into.

> ErrorHandler:
> debug.print "It continues to this line eventhough there is no error"

> --
> -oj
> Rac v2.1 Public Beta is RELEASED.
> http://www.rac4sql.net



> > It is highlighting the Select Case Err.Number line.  Sorry about the
> > inappropriate area, I thought it may have had something to do with SQL.

> > Thanks
> > Brad

 
 
 

Object variable or With block variable not set (Trapping SQL errors)

Post by oj » Wed, 07 Aug 2002 10:19:08


email me the vb code and i'll help...

--
-oj
Rac v2.1 Public Beta is RELEASED.
http://www.rac4sql.net


Quote:> Nope oj,

> The exit sub on my login routine is in fact in place.  If you need more
code
> just let me know.

> Thanks
> Brad

 
 
 

1. ODBC - Object variable or With block variable not set (Error 91)

Hi,
Can anybody provide me with any clues pn to what I'm doing
wrong on the module below?  The last line gives me an
error 91, I'm just totally stumped!

Sub GetMgrName()
         On Error Resume Next
         Dim WrkSp As Workspace
         Dim qdf As QueryDef
         Dim cnn As Connection
         Dim strConnect As String
         Dim strSQL As String
         Set WrkSp = CreateWorkspace
("ODBCDirect", "sa", "dangerwr", dbUseODBC)

strConnect="ODBC;DATABASE=EMPDB01;UID=sa;PWD=dangerwr;DSN=D
LH Base SQL Server"
         Set cnn = WrkSp.OpenConnection("Connection1",
dbDriverNoPrompt, True, strConnect)
         cnn.Execute strSQL
         On Error GoTo 0

          Set qdf = cnn.CreateQueryDef
("NewQueryDef", "SELECT * FROM dbemp01")

2. SQL ---Waiting For Worker Threads----

3. Error in DTS - Object variable or With block variable not set

4. Getting exclusive acces to a Paradox table

5. Cube processing error: Object variable or With block variable not set

6. Schizophrenic Procedures

7. error 91 Object Variable o on with block variable is not set

8. Retrieving a tree using SQL

9. Object variable or With block variable not set (Error 91)

10. Error: Object variable or with block variable not set

11. Object variable or With block variable not set (Error 91)

12. Object variable or With block variable not set

13. OLAP: Object Variable or With block variable not set