我正在爲一個學校項目製作一個應用程序。 不斷當我嘗試執行存儲過程時,我收到一條錯誤消息,提示語法無效。SQL語法錯誤,找不到
這是從VBA我的代碼和存儲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
而且我在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
代碼,我似乎無法得到它的工作,任何人都可以幫忙嗎?
顯示完整的錯誤訊息 – Jens
'35'(這是我輸入到TxTPrijs的輸入)附近的語法不正確 –
[如何在VBA中調試動態SQL](http://stackoverflow.com/questions/418960/managing- and-debugging-sql-queries-in-ms-access/1099570#1099570)。一個簡單的'Debug.Print <你想運行的EXEC字符串>'會顯示你的錯誤。 – Andre