I am making an application for a school project. And constantly when I try and execute a stored procedure I get an error message saying invalid syntax.
This is my code from Vba and stored proceduer
CREATE PROCEDURE spVeranderPrijs
(
@ArtikelNr integer,
@WijzigingsDatum Date,
@NieuwePrijs integer
)
AS
BEGIN Transaction
Select * from artikelprijs
where artikelnr = @ArtikelNr
and einddatum = '2099-01-01'
if @@ERROR <> 0
update ArtikelPrijs set einddatum = @Wijzigingsdatum
INSERT INTO Artikelprijs
VALUES (@ArtikelNr, @NieuwePrijs, @WijzigingsDatum, '2099-01-01');
BEGIN
ROLLBACK
RAISERROR ('Error tijdens het uitvoeren', 16 , 1)
RETURN
END
Commit
GO
And my code in Vba
Private Sub Command6_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sConnString As String
sConnString = "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;" & _
"Initial Catalog=KlantArtikelApp;" & _
"Integrated Security=SSPI;"
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open sConnString
Set rs = conn.Execute("EXEC spVeranderprijs '" & TxTArtikelNr & "', '" & TxTWijzigingsDatum & "' '" & TxTPrijs & "'")
End Sub
I cant seem to get it work, could anyone help?