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
@currentDateStr ing 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.Mai n.Variance, PFWTRAN.dbo.Mai n.AccVariance,
PFWTRAN.dbo.Mai n.TargetHours,
PFWTRAN.dbo.Tra nsactions.Date FROM PFWTRAN.dbo.Tra nsactions
INNER JOIN PFWTRAN.dbo.Mai n ON PFWTRAN.dbo.Tra nsactions.Date =
PFWTRAN.dbo.Mai n.Date AND
PFWTRAN.dbo.Tra nsactions.Token Number = PFWTRAN.dbo.Mai n.TokenNumber
WHERE (PFWTRAN.dbo.Tr ansactions.Toke nNumber = @tokenString) AND
(PFWTRAN.dbo.Tr ansactions.Date =
@currentDateStr ing)
END
GO
The code I am attempting to call the sp initially is the following:
Dim creditSqlConnec tion As New
SqlConnection(C onfigurationMan ager.AppSetting s("Plantime.Con nectionString2" ))
Dim creditSqlComman d As New SqlCommand("sp_ Datacredit",
creditSqlConnec tion)
.....
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 creditsqlcomman d
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
@currentDateStr ing 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.Mai n.Variance, PFWTRAN.dbo.Mai n.AccVariance,
PFWTRAN.dbo.Mai n.TargetHours,
PFWTRAN.dbo.Tra nsactions.Date FROM PFWTRAN.dbo.Tra nsactions
INNER JOIN PFWTRAN.dbo.Mai n ON PFWTRAN.dbo.Tra nsactions.Date =
PFWTRAN.dbo.Mai n.Date AND
PFWTRAN.dbo.Tra nsactions.Token Number = PFWTRAN.dbo.Mai n.TokenNumber
WHERE (PFWTRAN.dbo.Tr ansactions.Toke nNumber = @tokenString) AND
(PFWTRAN.dbo.Tr ansactions.Date =
@currentDateStr ing)
END
GO
The code I am attempting to call the sp initially is the following:
Dim creditSqlConnec tion As New
SqlConnection(C onfigurationMan ager.AppSetting s("Plantime.Con nectionString2" ))
Dim creditSqlComman d As New SqlCommand("sp_ Datacredit",
creditSqlConnec tion)
.....
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 creditsqlcomman d
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
Comment