Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error or access violation while executing stored proc

Status
Not open for further replies.

Alira

Programmer
Mar 21, 2001
77
CA
Hi!

I'm getting this error...
Here is my code:
Dim db As Connection
Dim rsLog As ADODB.Recordset
Dim comLog As New ADODB.Command

Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDASQL;dsn=mydcn;uid=Win2000;pwd=;database=mydatabase;"

With comLog

.ActiveConnection = db
.CommandType = adCmdStoredProc
.CommandText = usagelogupdate
.Execute

End With

StoredProc:

CREATE PROCEDURE [dbo].[mytable] AS
DECLARE @var char(3)
SET @var = datepart(mm,GETDATE())

delete from mytable where substring(myfield,1,3) = @var
GO

??? Have a great day!:)
 
Since you declared the @var as a char(3), you might want to use the DateName function that returns the character name (August) of the current month rather than datepart which returns the integer representing the month (8)

SET @var = datename(month,GETDATE())
/* char(3) truncates August to Aug */


delete from mytable where substring(myfield,1,3) = @var



Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top