473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object not set to a reference to an object 91 - HELP PLEASE

Hi guys,

i am not new to vb6, but a mere tyro in vb.net what i want to do is
the following

open transaction
build an ADODB command object using parameters
execute it
build another command
execute it
build another command
execute it

if all is well commit, else rollback.

my problem is that on the third execute, it dies with the above error.
this error seems to be comming out of cmd.activeconne ction.errors
collection. this odd because the connection object and the command
object both show open and in a legitimate state. the collection also
appears to have the right values

any and all help desperately needed. pls don't say use ado.net unless
you are prepared to post equivalent code.

all code is as follows:

** FIRST **
Private Function Add() As Boolean
Dim cmd As ADODB.Command
Dim u As New cUtilites
Dim cn As ADODB.Connectio n

cn = mdiMain.gDB.Con n

Try
FieldValue("Cli entID") = GetNewClientID( )
cmd = u.BuildCommand( "APP001_InsertE MCApps", RecCol(1))

cn.BeginTrans()

If mdiMain.gDB.Exe cute(cmd, cn) Then ** OK **
'append names
If Me.Names.Save(F ieldValue("clie ntid"), cn) Then
cn.CommitTrans( )
Else
cn.RollbackTran s()
End If
Else
cn.RollbackTran s()
End If
Catch ex As Exception
cn.RollbackTran s()
End Try

cmd = Nothing
u = Nothing

End Function

** SECOND **
Private Function Add(ByVal flds As Collection, Optional ByRef cn As
ADODB.Connectio n = Nothing) As Boolean
Dim cmd As ADODB.Command
Dim u As New cUtilites

cmd = u.BuildCommand( "APP003_InsertE MCNames", flds)
If Not IsNothing(cmd) Then
Add = mdiMain.gDB.Exe cute(cmd, cn)

Else
Add = False
End If

u = Nothing

End Function

Public Function Save(ByVal ClientID As String, Optional ByRef cn
As ADODB.Connectio n = Nothing) As Boolean
Dim flds As Collection
If FieldValue("con tid", "C") = "" Then
FieldValue("cli entid", "C") = ClientID
Save = Add(NamesCol("C "), cn) ** OK **
Else
Update()
End If

If FieldValue("con tid", "A") = "" Then
FieldValue("cli entid", "A") = ClientID
Save = Add(NamesCol("A "), cn) ** ERROR HERE **
Else
Update()
End If
flds = Nothing

End Function

** THIRD ****

Public Function Execute(ByRef cmd As ADODB.Command, Optional ByRef cn
As ADODB.Connectio n = Nothing) As Boolean
On Error Resume Next
'very old copied vb6 code
Dim lRecordsAffecte d As Long

'open connection if ConnectionTo is nothing
With cmd
If cn Is Nothing Then
.ActiveConnecti on = mCN
Else
.ActiveConnecti on = cn
End If
.CommandTimeout = 600
.Execute(lRecor dsAffected)

End With

With cmd.ActiveConne ction ** ERROR HERE AFTER 3RD EXECUTE
**
'put the native error in the errors collection
If .Errors.Count > 0 Then
Err.Raise(.Erro rs(0).NativeErr or, .Errors(0).Sour ce,
..Errors(0).Des cription)
End With
'try catch throw finally
If Err.Number = 0 Then
Execute = True
Else
Execute = False
MsgBox("Error in cDataServices.E xecute(). " & Err.Number &
" " & Err.Source & " " & Err.Description )
Err.Clear()
End If

cmd = Nothing

End Function
'builds the command object
Public Function BuildCommand(By Val SPname As String, ByVal fldCol As
Collection) As ADODB.Command

Dim strSql As String 'SQL string for Error
information
Dim strParams As String 'Param No for Error
information
Dim strNote As String 'Extra error info
Dim cmd As ADODB.Command
Dim FldLen As Integer

cmd = New ADODB.Command

Try
With cmd

.CommandType = ADODB.CommandTy peEnum.adCmdSto redProc
.CommandText = SPname

'Store all parameter and their values in a string for
error reporting
strParams = "Parameters passed to the SP " & SPname &
" are:"

'Following loop sets all the parameters
For Each fld As PType In fldCol
'Set the parameter for the prepared statement
Select Case fld.Datatype
Case ADODB.DataTypeE num.adChar,
ADODB.DataTypeE num.adVarChar
FldLen = IIf(Len(fld.var Value) = 0, 1,
Len(fld.varValu e))
Case Else
FldLen = fld.intLen
End Select
'debug
fld.varValue = YesNull(fld.var Value)
strParams = strParams & vbCrLf & "Name = " &
fld.FieldName & " Value = " & fld.varValue
.Parameters.App end(.CreatePara meter(fld.Field Name,
fld.Datatype, ADODB.Parameter DirectionEnum.a dParamInput, FldLen,
fld.varValue))
Next fld 'End of for loop

End With
Catch e As Exception
cmd = Nothing
MsgBox("build command " & e.Message)
End Try

Return cmd
End Function
Nov 20 '05 #1
0 1540

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10549
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server Error in '/Cr_Dataset' Application. ----------------------------------------------------------- ---------------------
106
5614
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the same as an assignment, but for class types it has a different effect - it calls the copy constructor. My question is when to not use an initalisation list for initialising data members of a class?
7
597
by: kon george | last post by:
Can somebody assist. I build this code on a dev laptop and copied across the entire code to a Windows 2003 server with 1.1 framework. It is basic ASP.NE T that uses web service for SQL Server 2000 DB access. The code works fine on my dev laptop, just not on the non dev machine. Here is the full error page:
11
9271
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
29
2302
by: web1110 | last post by:
If I have 2 variables, A and B, referencing the same object and then do a A.Dispose(), what happens to B?
3
2233
by: BakelNB | last post by:
I am new to the .Net environment, so please bear with me. I am passing a form object (e.g. formA) to an existing form (e.g. formB) by setting a property value defined in formB to hold the formA object. Please keep in mind that formB is defined in a separate library project. I then display formB. Once formB is displayed, I have code in a double click event procedure in formB to display formA by getting the form object throught the property...
5
2520
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj);
5
5021
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
3
2802
by: Belebele | last post by:
I have an Element class which is abstract and I would like to have an object of the Iterator class to iterate over a range of elements. I would like to use std::for_each to instrument the iteration, which forces me to have certain interface on the Iterator class. struct Element { virtual ~Element() = 0; };
275
12404
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.