S
si_owen
Hi,
I have never used stored procedures before and I am experiencing
problems when I am trying to call my sp in my vb code.
My project is a web app in visual studio 2005.
Here is my stored procedure:
CREATE PROCEDURE sp_dataCredit
@tokenString int
@currentDateString nvarchar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT TOP 1 PFWTRAN.dbo.Main.Variance, PFWTRAN.dbo.Main.AccVariance,
PFWTRAN.dbo.Main.TargetHours,
PFWTRAN.dbo.Transactions.Date FROM PFWTRAN.dbo.Transactions
INNER JOIN PFWTRAN.dbo.Main ON PFWTRAN.dbo.Transactions.Date =
PFWTRAN.dbo.Main.Date AND
PFWTRAN.dbo.Transactions.TokenNumber = PFWTRAN.dbo.Main.TokenNumber
WHERE (PFWTRAN.dbo.Transactions.TokenNumber = @tokenString) AND
(PFWTRAN.dbo.Transactions.Date =
@currentDateString)
END
GO
The code I am attempting to call the sp initially is the following:
Dim creditSqlConnection As New
SqlConnection(ConfigurationManager.AppSettings("Plantime.ConnectionString2"))
Dim creditSqlCommand As New SqlCommand("sp_Datacredit",
creditSqlConnection)
.....
The code directly above does connect to the sp, but ask's for values
for the two parameters, which is as I expected. However after a few
attempts to add the two parameter values into the creditsqlcommand
string, I have had plenty of error messages and no joy in solving
them.
Can anyone point me in the right direction on how to add the parameter
values to the call.
Thanks in advance,
Simon
I have never used stored procedures before and I am experiencing
problems when I am trying to call my sp in my vb code.
My project is a web app in visual studio 2005.
Here is my stored procedure:
CREATE PROCEDURE sp_dataCredit
@tokenString int
@currentDateString nvarchar(100)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT TOP 1 PFWTRAN.dbo.Main.Variance, PFWTRAN.dbo.Main.AccVariance,
PFWTRAN.dbo.Main.TargetHours,
PFWTRAN.dbo.Transactions.Date FROM PFWTRAN.dbo.Transactions
INNER JOIN PFWTRAN.dbo.Main ON PFWTRAN.dbo.Transactions.Date =
PFWTRAN.dbo.Main.Date AND
PFWTRAN.dbo.Transactions.TokenNumber = PFWTRAN.dbo.Main.TokenNumber
WHERE (PFWTRAN.dbo.Transactions.TokenNumber = @tokenString) AND
(PFWTRAN.dbo.Transactions.Date =
@currentDateString)
END
GO
The code I am attempting to call the sp initially is the following:
Dim creditSqlConnection As New
SqlConnection(ConfigurationManager.AppSettings("Plantime.ConnectionString2"))
Dim creditSqlCommand As New SqlCommand("sp_Datacredit",
creditSqlConnection)
.....
The code directly above does connect to the sp, but ask's for values
for the two parameters, which is as I expected. However after a few
attempts to add the two parameter values into the creditsqlcommand
string, I have had plenty of error messages and no joy in solving
them.
Can anyone point me in the right direction on how to add the parameter
values to the call.
Thanks in advance,
Simon