473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Difficulty uploading information to database

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

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200512/1
Dec 1 '05 #1
2 1077
you sp does not validate its data, and fails silently. try:

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
if @@rowcount = 0 raiserror('no matching customer/cart combo found',16,1)

GO
-- bruce (sqlwork.com)

"martinharvey via DotNetMonster.com" <u14945@uwe> wrote in message
news:582d64a1814cc@uwe...
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

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200512/1

Dec 1 '05 #2
Bruce Barker wrote:
you sp does not validate its data, and fails silently. try:

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
if @@rowcount = 0 raiserror('no matching customer/cart combo found',16,1)

GO

-- bruce (sqlwork.com)
This is probably a very simple question but i am having problems with
inserting information into database

[quoted text clipped - 60 lines]

martin


thanks for your help Bruce

I eventually got it to work

many thanks

martin

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...p-net/200512/1
Dec 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: needin4mation | last post by:
Hi, I am uploading a file and changing a record in a database. When the database is updated, I retrieve the last_insert_id() to get the latest row key. I also have a Page_Load event that...
3
by: Carlos | last post by:
Hello Forum, I would appreciate it if you could recommend settings to use auto-vacuum in my version 7.4 database. I am uploading several thousands records in the database at a rate of ~1 second...
4
by: Kevin D. | last post by:
I have a web application that continues to "break" on me after a random amount of time. There doesn't appear to be a rhyme or reason, just out of nowhere some of my error handling kicks in and...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
4
by: Rob Meade | last post by:
Dear all, We have purchased a product called SA-FileUp which we have used in our organisation for a number of years, I'm quite an an avid supporter of it, recently I've been trying to ensure...
14
w33nie
by: w33nie | last post by:
What I'm trying to do here, is upload a video to the ../video/ folder, and up to 5 images to the ../images/ folder. As well as the database information like title, content and each file's file...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
2
by: matech | last post by:
I have a problem with uploading special characters from excel files to mysql 5. It doesn't matter if I use UTF-8 or iso-8859-1 when uploading the trademark ™ symbol. htmlspecialchars() or...
7
by: nwclark | last post by:
Ok... I have a noobie issue. I am trying to upload a photo to specific directory on my server. (this is working correctly with the code below). However, I am also trying to rename the file and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.