ASPNETnewbie
Programmer
I can't seem to execute the code below with my SQL compiler and I was wondering if anyone can help me understand what is wrong with this and How I can go about fixing the problem.
The Main error I keep getting is with the GO keyword
Error Source: .Net sqlClient Data Provider
Error Message: Incorrect Syntax near 'GO'
Must declare the scalar variable "@Name"
Incorrect syntax near the keyword 'PROCEDURE"
Incorrect Syntax near 'GO'
Must declare the scalar variable "@Name"
Must declare the scalar variable "@Address1"
Must Declare the scalar variable"@CreditCard"
===========================================================
SQL CODE
===========================================================
CREATE PROCEDURE GetCustomerIDPassword
(@Email varchar(50))
AS
SELECT CustomerID, [Password]
FROM Customer
WHERE Email = @Email
GO
CREATE PROCEDURE AddCustomer
(@Name varchar(50),
@Email varchar(50),
@Password varchar(50),
@Phone varchar(100))
AS
DECLARE @CustomerID AS int
INSERT INTO Customer ([Name], Email, [Password], Phone)
VALUES (@Name, @Email, @Password, @Phone)
SET @CustomerID = @@IDENTITY
SELECT @CustomerID
GO
CREATE PROCEDURE GetCustomer
(@CustomerID varchar(50))
AS
SELECT CustomerID, [Name], [Password], Email, CreditCard, Address1, Address2, City,
Region, PostalCode, Country, Phone
FROM Customer
WHERE CustomerID = @CustomerID
GO
CREATE PROCEDURE UpdateCustomerDetails
(@CustomerID int,
@Name varchar(50),
@Email varchar(50),
@Password varchar(50),
@Phone varchar(100))
AS
UPDATE Customer
SET [Name] = @Name, Email = @Email, [Password] = @Password, Phone = [Phone]
WHERE CustomerID = @CustomerID
GO
CREATE PROCEDURE UpdateAddress
(@CustomerID int,
@Address1 varchar(100),
@Address2 varchar(100),
@City varchar(100),
@Region varchar(100),
@PostalCode varchar(100),
@Country varchar(100)
)
AS
UPDATE Customer
SET Address1 = @Address1, Address2 = @Address2, City = @City, Region = @Region,
PostalCode = @PostalCode, Country = @Country
WHERE CustomerID = @CustomerID
GO
CREATE PROCEDURE UpdateCreditCard
(@CustomerID int,
@CreditCard varchar(512))
AS
UPDATE Customer
SET CreditCard = @CreditCard
WHERE CustomerID = @CustomerID
GO
The Main error I keep getting is with the GO keyword
Error Source: .Net sqlClient Data Provider
Error Message: Incorrect Syntax near 'GO'
Must declare the scalar variable "@Name"
Incorrect syntax near the keyword 'PROCEDURE"
Incorrect Syntax near 'GO'
Must declare the scalar variable "@Name"
Must declare the scalar variable "@Address1"
Must Declare the scalar variable"@CreditCard"
===========================================================
SQL CODE
===========================================================
CREATE PROCEDURE GetCustomerIDPassword
(@Email varchar(50))
AS
SELECT CustomerID, [Password]
FROM Customer
WHERE Email = @Email
GO
CREATE PROCEDURE AddCustomer
(@Name varchar(50),
@Email varchar(50),
@Password varchar(50),
@Phone varchar(100))
AS
DECLARE @CustomerID AS int
INSERT INTO Customer ([Name], Email, [Password], Phone)
VALUES (@Name, @Email, @Password, @Phone)
SET @CustomerID = @@IDENTITY
SELECT @CustomerID
GO
CREATE PROCEDURE GetCustomer
(@CustomerID varchar(50))
AS
SELECT CustomerID, [Name], [Password], Email, CreditCard, Address1, Address2, City,
Region, PostalCode, Country, Phone
FROM Customer
WHERE CustomerID = @CustomerID
GO
CREATE PROCEDURE UpdateCustomerDetails
(@CustomerID int,
@Name varchar(50),
@Email varchar(50),
@Password varchar(50),
@Phone varchar(100))
AS
UPDATE Customer
SET [Name] = @Name, Email = @Email, [Password] = @Password, Phone = [Phone]
WHERE CustomerID = @CustomerID
GO
CREATE PROCEDURE UpdateAddress
(@CustomerID int,
@Address1 varchar(100),
@Address2 varchar(100),
@City varchar(100),
@Region varchar(100),
@PostalCode varchar(100),
@Country varchar(100)
)
AS
UPDATE Customer
SET Address1 = @Address1, Address2 = @Address2, City = @City, Region = @Region,
PostalCode = @PostalCode, Country = @Country
WHERE CustomerID = @CustomerID
GO
CREATE PROCEDURE UpdateCreditCard
(@CustomerID int,
@CreditCard varchar(512))
AS
UPDATE Customer
SET CreditCard = @CreditCard
WHERE CustomerID = @CustomerID
GO