Command Object

Hi,

I have the following function in my Main Module (VB) .


Public Function Insert_LogFile(ByRef P_LogType As String, ByRef P_JrlType As String, _
ByRef p_TrnNo As String, ByRef P_LogDescription As String, _
ByRef P_LogEssential As Integer)
'This Function will create a Entry in Log Table and return the LogId of the Newly created Row
'Declaring the INPUT Parameters for the Command Object
Dim parCompanyID As Parameter, parFinyear As Parameter
Dim parLogType As Parameter, parLogDate As Parameter
Dim parLogTime As Parameter, parLogMenuName As Parameter
Dim parJrlType As Parameter, parTrnNo As Parameter
Dim parLogDesc As Parameter, parLogIP As Parameter
Dim parUserID As Parameter, parLogEssential As Parameter
'Declaring the OUTPUT parameter
Dim parLogID As Parameter
'Declaring the Command Object
Dim cmdlog As New ADODB.Command
Dim rstLog As New ADODB.Recordset
'Initializing the Command Object
Set cmdlog.ActiveConnection = g_m_cnnIMS
cmdlog.CommandText = "dbo.Sp_LogFile"
cmdlog.CommandType = adCmdStoredProc
' Setting up the Parameters
Set parCompanyID = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parCompanyID
parCompanyID.Value = g_m_openCompID
Set parFinyear = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parFinyear
parFinyear.Value = g_m_finYear
Set parLogType = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogType
parLogType.Value = P_LogType
Set parLogDate = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogDate
parLogDate.Value = Date
Set parLogTime = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogTime
parLogTime.Value = Time
Set parLogMenuName = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogMenuName
parLogMenuName.Value = g_m_LogMenuName
Set parJrlType = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parJrlType
parJrlType.Value = P_JrlType
Set parTrnNo = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parTrnNo
parTrnNo.Value = p_TrnNo
Set parLogDesc = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogDesc
parLogDesc.Value = P_LogDescription
Set parLogIP = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogIP
parLogIP.Value = g_m_CompNameIP
Set parUserID = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parUserID
parUserID.Value = g_m_UserID
Set parLogEssential = cmdlog.CreateParameter("Input", adVarChar, adParamInput)
cmdlog.Parameters.Append parLogEssential
parLogEssential.Value = P_LogEssential
Set parLogID = cmdlog.CreateParameter("Output", adVarChar, adParamOutput)
cmdlog.Parameters.Append parLogID
Set rstLog = cmdlog.Execute
Debug.Print cmdlog(13)
End Function


I am getting the the Error Called "Class does not support Automation or does not support expected interface" while executing the Line

"Set cmdlog.ActiveConnection = g_m_cnnIMS"


Why this Error Comes ?

Pls Help ..

Suresh...
[3572 byte] By [Surr_79] at [2007-11-19 1:54:17]
# 1 Re: Command Object
I wouldn't normally use the SET statement when assigning the .ACTIVECONNECTION property, but then I do it as follows:

dim cmdlog as adodb.command

set cmdlog = new adodb.command
with cmdlog
.activeconnection = adoconnection
'etc
end with

I don't suppose there's much between the two, except for the way we are setting the active connection property.
jp140768 at 2007-11-9 21:00:47 >
# 2 Re: Command Object
Make sure you have the correct MDAC version on the computer.
malleyo at 2007-11-9 21:01:54 >
# 3 Re: Command Object
You can use this to check the MDAC/ADO Version. Open a new VB project and paste this code into the form's code window.

Option Explicit

Function GetAdoVersion() As String
'Returns an empty string if ADO is not installed
Dim o As Object

On Error Resume Next
Set o = CreateObject("ADODB.Connection")

If Err.Number = 0 Then
GetAdoVersion = o.Version
Label1.Caption = "ADO Version = " & o.Version
Else
Label1.Caption = "ADO is not installed"
End If

End Function

Private Sub Form_Load()
Call GetAdoVersion
End Sub
malleyo at 2007-11-9 21:02:58 >
# 4 Re: Command Object
Thanks Malleyo,

I have Installed MDAC version 2.6 and now i gave no problem with Command Object ..

Thanks to all Who replied for me ...

Suresh ...
Surr_79 at 2007-11-9 21:03:59 >