I am trying to pass a simple parameter to a stored procedure from vb6 and recieve the above error.
heres the vb bit:
Private Sub Command1_Click()
Dim cnn As Connection
Dim rst As Recordset
Dim Command1 As Command
' Instantiate the object variables
Set cnn = New Connection
Set Command1 = New Command
Set rst = New Recordset
' Establish a connection to the database
With cnn
.Provider = "SQLOLEDB"
.ConnectionString = "server=xxxxx;uid=sa;pwd=;database=dreamtec"
.Open
End With
' Create the Command object
With Command1
.CommandType = adCmdStoredProc
' set the name of the stored procedure
.CommandText = "spprojectcode"
' create and append the input parameter
.Parameters.Append Command1.CreateParameter("projectcode", adChar)
' set the initial value of the parameter
.Parameters("projectcode"
.Value = Text1.Text
' set the connection
.ActiveConnection = cnn
End With
' call the stored proc and save the results in a recordset
Set rst = Command1.Execute
End Sub
and heres the SQL Server sp:
CREATE PROCEDURE spProjectCode @ProjectCode char (10) AS
select * from tblmeeting
where ProjectCode=@ProjectCode
I have an identical procedure which works fine when the parameter is an int for the sp .... why does it not work when passing a text parameter?
Can someone point me in the direction of what I am doing wrong?
heres the vb bit:
Private Sub Command1_Click()
Dim cnn As Connection
Dim rst As Recordset
Dim Command1 As Command
' Instantiate the object variables
Set cnn = New Connection
Set Command1 = New Command
Set rst = New Recordset
' Establish a connection to the database
With cnn
.Provider = "SQLOLEDB"
.ConnectionString = "server=xxxxx;uid=sa;pwd=;database=dreamtec"
.Open
End With
' Create the Command object
With Command1
.CommandType = adCmdStoredProc
' set the name of the stored procedure
.CommandText = "spprojectcode"
' create and append the input parameter
.Parameters.Append Command1.CreateParameter("projectcode", adChar)
' set the initial value of the parameter
.Parameters("projectcode"
' set the connection
.ActiveConnection = cnn
End With
' call the stored proc and save the results in a recordset
Set rst = Command1.Execute
End Sub
and heres the SQL Server sp:
CREATE PROCEDURE spProjectCode @ProjectCode char (10) AS
select * from tblmeeting
where ProjectCode=@ProjectCode
I have an identical procedure which works fine when the parameter is an int for the sp .... why does it not work when passing a text parameter?
Can someone point me in the direction of what I am doing wrong?