M
martinharvey via DotNetMonster.com
This is probably a very simple question but i am having problems with
inserting information into database
The function takes the values "FirstName" And "LastName" from a table Called
"Customer" and the value "ProductID" from a table called "Products" and
inserts them into a table called " NewOrder".
Everything compiles ok but when I press the button the information is not
uploaded to the
database. ( There is no error message)
This is the stored procedure
CREATE PROCEDURE SP_NewOrder
(@CartID char (36), @CustomerID Varchar (50))
AS
INSERT INTO NewOrder (FirstName, LastName, ProductID)
SELECT Customer.FirstName, Customer.LastName, Products.ProductID
From Customer,Products Join ShoppingCart ON Products.ProductID =ShoppingCart.
ProductID
WHERE ShoppingCart.CartID = @CartID AND Customer.CustomerID = @CustomerID
GO
This is the Function
Public Shared Function CreateOrder() AS String
Dim customerID As integer
Dim connection as New SqlConnection(connectionString)
Dim command as New SqlCommand("SP_NewOrder",connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@CartID", SqlDbType.Char,36)
command.Parameters("@CartID").Value = shoppingCartID
command.Parameters.Add("@CustomerID", SqlDbType.Varchar,36)
command.Parameters("@CustomerID").Value = customerID
Try
connection.Open()
command.ExecuteNonQuery()
Finally
connection.Close()
End Try
End Function
This is the page code
Sub btn3_Click(sender As Object, e As EventArgs)
Dim cart as New ShoppingCart()
Dim shoppingCartID As Integer
Dim customerID As Integer = Context.Session("worldshop_CustomerID")
cart.CreateOrder()
End Sub
Can Anyone see where I am going wrong
Many thanks
martin
inserting information into database
The function takes the values "FirstName" And "LastName" from a table Called
"Customer" and the value "ProductID" from a table called "Products" and
inserts them into a table called " NewOrder".
Everything compiles ok but when I press the button the information is not
uploaded to the
database. ( There is no error message)
This is the stored procedure
CREATE PROCEDURE SP_NewOrder
(@CartID char (36), @CustomerID Varchar (50))
AS
INSERT INTO NewOrder (FirstName, LastName, ProductID)
SELECT Customer.FirstName, Customer.LastName, Products.ProductID
From Customer,Products Join ShoppingCart ON Products.ProductID =ShoppingCart.
ProductID
WHERE ShoppingCart.CartID = @CartID AND Customer.CustomerID = @CustomerID
GO
This is the Function
Public Shared Function CreateOrder() AS String
Dim customerID As integer
Dim connection as New SqlConnection(connectionString)
Dim command as New SqlCommand("SP_NewOrder",connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@CartID", SqlDbType.Char,36)
command.Parameters("@CartID").Value = shoppingCartID
command.Parameters.Add("@CustomerID", SqlDbType.Varchar,36)
command.Parameters("@CustomerID").Value = customerID
Try
connection.Open()
command.ExecuteNonQuery()
Finally
connection.Close()
End Try
End Function
This is the page code
Sub btn3_Click(sender As Object, e As EventArgs)
Dim cart as New ShoppingCart()
Dim shoppingCartID As Integer
Dim customerID As Integer = Context.Session("worldshop_CustomerID")
cart.CreateOrder()
End Sub
Can Anyone see where I am going wrong
Many thanks
martin