kshireesh
asked on
Export the recordset to excel from VB
Hi
I am using a stored procedure and the setting it equal to a record set. How do i see and export the data to excel via excel object in VB6.
Set cmd = New Command
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "PlanActalData"
cmd.Parameters.Append cmd.CreateParameter("Repor tReleaseID ", adVarChar, adParamInput, 255, cboReportRelease.Text)
cmd.Parameters.Append cmd.CreateParameter("Repor tCycleID", adVarChar, adParamInput, 255, cboReportTestCycle.Text)
cmd.Parameters.Append cmd.CreateParameter("Repor tBuildID", adVarChar, adParamInput, 255, cboReportBuild.Text)
'cmd.Parameters.Append cmd.CreateParameter("resul t", adInteger, adParamOutput)
' rsGetActualData.Open cmd, con, adOpenForwardOnly, adLockReadOnly
'cmd.Execute
'rsGetActualData.Open cmd.Execute, con, adOpenDynamic, adLockReadOnly
Dim rsCount As Integer
'MsgBox rsCount
Set rsGetActualData = cmd.Execute(ra)
I am using a stored procedure and the setting it equal to a record set. How do i see and export the data to excel via excel object in VB6.
Set cmd = New Command
cmd.ActiveConnection = con
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "PlanActalData"
cmd.Parameters.Append cmd.CreateParameter("Repor
cmd.Parameters.Append cmd.CreateParameter("Repor
cmd.Parameters.Append cmd.CreateParameter("Repor
'cmd.Parameters.Append cmd.CreateParameter("resul
' rsGetActualData.Open cmd, con, adOpenForwardOnly, adLockReadOnly
'cmd.Execute
'rsGetActualData.Open cmd.Execute, con, adOpenDynamic, adLockReadOnly
Dim rsCount As Integer
'MsgBox rsCount
Set rsGetActualData = cmd.Execute(ra)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
The recordset which is passed to the function should be open at the time of function call. I have tried to execute the function and it 100000 % working dear...! I am using the same function for all my projects from last 8 years...!
Just make sure the recordset object is not closed. Check your cursor type also.... ( client side or server side ) Make necessary changes , and you will definitely get the data in Excel.
RAHUL
Confirmed. This code works perfectly.
Don't forget to add the reference to Excel.
Don't forget to add the reference to Excel.
ASKER
thats how i making a function call
Call ExportToExcel(rsGetActualD
the error is
3704: Object is not allowed when the object is closed.
i still beleive the anomaly is at Set rsGetActualData = cmd.Execute(ra)
ra = 2 but rsGetActualData.recordcoun