Hi All,
I have been struggling with this error for 3 days now.I have a stored procedure as following:
Create procedure dbo.Search
(@BeginDate DateTime,
@EndDate DateTime)
As
DECLARE @vBeginDate NVARCHAR(20)
DECLARE @vEndDate NVARCHAR(20)
DECLARE @vStrSQL NVARCHAR(2000)
IF @BeginDate IS NOT NULL OR @EndDate IS NOT NULL
BEGIN
IF @BeginDate IS NULL
SELECT @BeginDate = MIN(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
IF @EndDate IS NULL
SELECT @EndDate = MAX(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
SET @vBeginDate = convert(VARCHAR(12), @begindate, 102)
SET @vEndDate = convert(VARCHAR(12), @EndDate, 102)
SET @vstrsql = 'SELECT * FROM tblApplication A where a.appRecddate between ''' +
@vBeginDate + ''' and ''' + @vEndDate + ''''
END
exec (@vStrSQL)
*********
when either of the prameters are Null I get an error message saying:
The object you have entered is not a valid RecordSet Property.
here is the VBA code:
Set rst = New ADODB.Recordset
With rst
Set .ActiveConnection = m_cnOnsite
.Source = "Exec search '1/1/1992', NULL "
.CursorLocation = adUseClient
.LockType = adLockReadOnly
.Open Options:=adCmdText
End With
The error occur on .Open
Any help would be greatly appreciated
Azita
I have been struggling with this error for 3 days now.I have a stored procedure as following:
Create procedure dbo.Search
(@BeginDate DateTime,
@EndDate DateTime)
As
DECLARE @vBeginDate NVARCHAR(20)
DECLARE @vEndDate NVARCHAR(20)
DECLARE @vStrSQL NVARCHAR(2000)
IF @BeginDate IS NOT NULL OR @EndDate IS NOT NULL
BEGIN
IF @BeginDate IS NULL
SELECT @BeginDate = MIN(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
IF @EndDate IS NULL
SELECT @EndDate = MAX(A.ApprecdDate)
FROM WQOnsite.dbo.tblApplication A
SET @vBeginDate = convert(VARCHAR(12), @begindate, 102)
SET @vEndDate = convert(VARCHAR(12), @EndDate, 102)
SET @vstrsql = 'SELECT * FROM tblApplication A where a.appRecddate between ''' +
@vBeginDate + ''' and ''' + @vEndDate + ''''
END
exec (@vStrSQL)
*********
when either of the prameters are Null I get an error message saying:
The object you have entered is not a valid RecordSet Property.
here is the VBA code:
Set rst = New ADODB.Recordset
With rst
Set .ActiveConnection = m_cnOnsite
.Source = "Exec search '1/1/1992', NULL "
.CursorLocation = adUseClient
.LockType = adLockReadOnly
.Open Options:=adCmdText
End With
The error occur on .Open
Any help would be greatly appreciated
Azita