BruceG
Oct 5th, 2000, 07:59 PM
I am in the process of teaching myself SQL Server, using the desktop edition of SQL Server 7 on a Win 98 platform. I am using the Wrox book "Beginning VB SQL Server 7" by Thearon Willis. I have been working thru the examples in the book and have had no problem whatsoever up to this point, and I am baffled by this problem.
I'm on Chapter 7, "Introduction to Stored Procedures", which has us writing basic stored procedures to insert, update, and delete data from a table of States. These SP's are then executed from a sample VB program. The insert and update procedures work beautifully, but the delete procedure produces the following error when executed from VB:
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '#'
('#' is the value of the parameter I'm passing it, which is the state_ID primary key field (an integer))
The State_T table has the following fields:
State_ID (int, PK, ID)
State_Name_VC (varchar(15))
State_Abbreviation_CH (char(2))
Last_Update_DT (datetime)
The contents of the stored procedure looks like this:
CREATE PROCEDURE up_parmdel_state_name (@State_ID Int) AS
DELETE FROM State_T
WHERE State_ID = @State_ID
This SP passes the syntax checks in Enterprise Manager and Query Analyzer, but the above-mentioned error occurs when VB executes the following statements:
' build the SQL string
strSQL = "BruceG.up_parmdel_state_name (" & lngStateID & ")"
'Delete the state data
objConn.Execute strSQL
lngStateID definitely has a good value coming into this function, and objConn is the same connection used for the insert and update procedures, which work fine. Also, the same permissions that were assigned to insert and update SPs were assigned to the delete SP.
What's more, I downloaded the author's code from the Wrox website (which is the same as what's in the book, which I am keying the code from; the only difference is the owner name ("willist" vs. "BruceG")) and it produces the same error.
This is what should be a simple example and I am totally stumped. Any ideas?
I'm on Chapter 7, "Introduction to Stored Procedures", which has us writing basic stored procedures to insert, update, and delete data from a table of States. These SP's are then executed from a sample VB program. The insert and update procedures work beautifully, but the delete procedure produces the following error when executed from VB:
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '#'
('#' is the value of the parameter I'm passing it, which is the state_ID primary key field (an integer))
The State_T table has the following fields:
State_ID (int, PK, ID)
State_Name_VC (varchar(15))
State_Abbreviation_CH (char(2))
Last_Update_DT (datetime)
The contents of the stored procedure looks like this:
CREATE PROCEDURE up_parmdel_state_name (@State_ID Int) AS
DELETE FROM State_T
WHERE State_ID = @State_ID
This SP passes the syntax checks in Enterprise Manager and Query Analyzer, but the above-mentioned error occurs when VB executes the following statements:
' build the SQL string
strSQL = "BruceG.up_parmdel_state_name (" & lngStateID & ")"
'Delete the state data
objConn.Execute strSQL
lngStateID definitely has a good value coming into this function, and objConn is the same connection used for the insert and update procedures, which work fine. Also, the same permissions that were assigned to insert and update SPs were assigned to the delete SP.
What's more, I downloaded the author's code from the Wrox website (which is the same as what's in the book, which I am keying the code from; the only difference is the owner name ("willist" vs. "BruceG")) and it produces the same error.
This is what should be a simple example and I am totally stumped. Any ideas?