Urgent, Please Help!!

Results 1 to 4 of 4

Thread: Urgent, Please Help!!

  1. #1
    Charles Guest

    Default Urgent, Please Help!!

    Hello, I am getting the following error: Runtime error 91, object variable a with block variable not set.<BR><BR>at line var2.open<BR><BR><BR>Any ideas what&#039;s wrong with current syntax? here is my code:<BR><BR><BR>VB:<BR>***<BR><BR> Private Sub Command1_Click()<BR> Dim AccountNumber As String<BR> AccountNumber = "test12345"<BR> Set var1 = CreateObject("SNCls3.SNOrderDir3")<BR> Set var2 = var1.GetOrderTest(AccountNumber)<BR> var2.Open<BR> Do While Not var2.EOF<BR> List1.AddItem var2.Fields("symbol")<BR> var2.MoveNext<BR> Loop<BR> var2.Close<BR> Set var1 = Nothing<BR> Set var2 = Nothing<BR> End Sub<BR><BR>COM<BR>***<BR><BR>Public Function GetOrderTest(AccountNumber) As ADODB.recordset<BR> <BR> Dim objOContext As ObjectContext<BR> Set objOContext = GetObjectContext()<BR> <BR> Dim lErrNo As Long<BR> Dim sErrDesc As String<BR> <BR> On Error GoTo ErrorHandler<BR> <BR> Dim GetOrders As New Collection<BR> <BR> Dim objConn As New ADODB.connection<BR> Dim objRS As New ADODB.recordset<BR> Dim objCommand As New ADODB.Command<BR> Dim objParam As New ADODB.Parameter<BR> With objConn<BR> .ConnectionString = DB_CONNECTIONSTRING<BR> .Open<BR> End With<BR> &#039;Use command object to send accountnumber to stored procedure<BR> &#039;******************************************** ****************<BR> Set objCommand = New ADODB.Command<BR> With objCommand<BR> .CommandText = "GetTest"<BR> .CommandType = adCmdStoredProc<BR> .ActiveConnection = objConn<BR> End With<BR> Set objParam = objCommand.CreateParameter("@AccountNumber", adVarChar, adParamInput, 9, AccountNumber)<BR> objCommand.Parameters.Append objParam<BR> Set objRS = objCommand.Execute<BR> &#039;******************************************** **************************<BR> objRS.Open "GetTest", connection, adOpenForwardOnly, adLockReadOnly, adCmdText<BR> Set GetOrderTest = objRS<BR><BR>objRS.ActiveConnection = Nothing<BR> Set objRS = Nothing<BR> Set objCommand = Nothing<BR> objOContext.SetComplete<BR> Set objOContext = Nothing<BR> Set GetOrderTest = GetOrders<BR> Set objParam = Nothing<BR> objConn.Close<BR> Set objConn = Nothing<BR> Exit Function<BR><BR>

  2. #2
    Hiram Guest

    Default RE: Urgent, Please Help!!

    If this is a VB program, make sure you have a reference set to the SNCls3 object. Without a reference being set, you will get this error.<BR><BR>Hope this helps.

  3. #3
    Charles Guest

    Default RE: Urgent, Please Help!!

    I do have a reference set to the SNCls3 component, any other suggestions?<BR><BR>Thanks

  4. #4
    Hiram Guest

    Default RE: Urgent, Please Help!!

    Not sure, but I saw something in your code that does not make sense to me. After you get the recordset built you assign it to the result object with this statement:<BR><BR>Set GetOrderTest = objRS <BR><BR>Further down from there you do this:<BR><BR>Set GetOrderTest = GetOrders <BR><BR>GetOrders is defined as a Collection and in your VB code you are trying to do an ADO Open against the object being returned by the COM object. This should be an ADO recordset (as you set by the first Set) and not a Collection.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts