bernardsylunar
Programmer
hi everyone,
i've created a stored procedure:
CREATE PROCEDURE GetAllRecords
@Tbl nvarchar(256), @Fld nvarchar(256), @FldValue nvarchar(256)
AS
declare @tsql varchar(100)
set @tsql='SELECT * FROM ' + @Tbl + ' where ' + @Fld + ' = ' + @FldValue
exec ( @tsql )
GO
where
@Tbl is for table name
@Fld is a field of the table
@FldValue is the value of the field
and call it from my VB module with this code:
Set Cn = New ADODB.Connection
Set sRecordset = New ADODB.Recordset
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = Cn
.CommandType = adCmdStoredProc
.CommandText = "GetAllRecords"
.Parameters.Append .CreateParameter("@Tbl", adVarChar, adParamInput, 9, "memo_info")
.Parameters.Append .CreateParameter("@Fld", adVarChar, adParamInput, 10, "email_from")
.Parameters.Append .CreateParameter("@FldValue", adVarChar, adParamInput, 7, "bslunar")
Set Rs = .Execute
End With
when i run my application, i got this error 'Invalid column name 'bslunar'
do i miss something in creating my store procedure or in calling it from my VB code?
thanks
ynad
----
It is foolish to listen to someone who will not listen to you.
i've created a stored procedure:
CREATE PROCEDURE GetAllRecords
@Tbl nvarchar(256), @Fld nvarchar(256), @FldValue nvarchar(256)
AS
declare @tsql varchar(100)
set @tsql='SELECT * FROM ' + @Tbl + ' where ' + @Fld + ' = ' + @FldValue
exec ( @tsql )
GO
where
@Tbl is for table name
@Fld is a field of the table
@FldValue is the value of the field
and call it from my VB module with this code:
Set Cn = New ADODB.Connection
Set sRecordset = New ADODB.Recordset
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = Cn
.CommandType = adCmdStoredProc
.CommandText = "GetAllRecords"
.Parameters.Append .CreateParameter("@Tbl", adVarChar, adParamInput, 9, "memo_info")
.Parameters.Append .CreateParameter("@Fld", adVarChar, adParamInput, 10, "email_from")
.Parameters.Append .CreateParameter("@FldValue", adVarChar, adParamInput, 7, "bslunar")
Set Rs = .Execute
End With
when i run my application, i got this error 'Invalid column name 'bslunar'
do i miss something in creating my store procedure or in calling it from my VB code?
thanks
ynad
----
It is foolish to listen to someone who will not listen to you.