473,503 Members | 13,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp.net update records using sql stored procedures

I have used stored procedures to insert and select but for some reason I can
not get this code to update records. Please help I must have made a dumb
mistake

STORED PROCEDURE
CREATE Procedure OrdersAddDetail
( @fname nvarchar(50),
@lnametxt nvarchar(50),
@add1 nvarchar(50),
@add2 nvarchar(50),
@city nvarchar(50),
@state nvarchar(50),
@zip nvarchar(50),
@phone nvarchar(50),
@bfname nvarchar(50),
@blname nvarchar(50),
@badd1 nvarchar(50),
@badd2 nvarchar(50),
@bcity nvarchar(50),
@bstate nvarchar(50),
@bzip nvarchar(50),
@bphone nvarchar(50),
@CustomerID int
)
AS

UPDATE Customers

SET
fname = @fname,
lname = @lnametxt,
add1 = @add1,
add2 = @add2,
city = @city,
state = @state,
zip = @zip,
phone = @phone,
bfname = @bfname,
blname = @blname,
badd1 = @badd1,
badd2 = @badd2,
bcity = @bcity,
bstate = @bstate,
bzip = @bzip,
bphone = @bphone
WHERE
CustomerID = @CustomerID
GO

SUB

Public Sub UpdateAdd(ByVal customerID As Integer, ByVal fnametxt As String,
ByVal lname As String, ByVal add1 As String, ByVal add2 As String, ByVal city
As String, ByVal state As String, ByVal zip As String, ByVal phone As String,
ByVal bfname As String, ByVal blname As String, ByVal badd1 As String, ByVal
badd2 As String, ByVal bcity As String, ByVal bstate As String, ByVal bzip As
String, ByVal bphone As String)
' Create Instance of Connection and Command Object
Dim myConnection2 As SqlConnection = New
SqlConnection(ConfigurationManager.AppSettings("Co nnectionString"))
Dim myCommand2 As SqlCommand = New SqlCommand("OrdersAddDetail",
myConnection2)

' Mark the Command as a SPROC
myCommand2.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC
Dim parameterCustomerID As SqlParameter = New
SqlParameter("@CustomerID", SqlDbType.Int, 4)
parameterCustomerID.Value = CInt(customerID)
myCommand2.Parameters.Add(parameterCustomerID)

'Dim parameterOrderID As SqlParameter = New
SqlParameter("@OrderID", SqlDbType.Int, 4)
'parameterOrderID.Direction = ParameterDirection.Output
'myCommand2.Parameters.Add(parameterOrderID)

Dim parameterfname As SqlParameter = New SqlParameter("@fname",
SqlDbType.NVarChar, 50)
parameterfname.Value = fnametxt
myCommand2.Parameters.Add(parameterfname)

Dim parameterlname As SqlParameter = New
SqlParameter("@lnametxt", SqlDbType.NVarChar, 50)
parameterlname.Value = lname
myCommand2.Parameters.Add(parameterlname)

Dim parameteradd1 As SqlParameter = New SqlParameter("@add1",
SqlDbType.NVarChar, 50)
parameteradd1.Value = add1
myCommand2.Parameters.Add(parameteradd1)

Dim parameteradd2 As SqlParameter = New SqlParameter("@add2",
SqlDbType.NVarChar, 50)
parameteradd2.Value = add2
myCommand2.Parameters.Add(parameteradd2)

Dim parametercity As SqlParameter = New SqlParameter("@city",
SqlDbType.NVarChar, 50)
parametercity.Value = city
myCommand2.Parameters.Add(parametercity)

Dim parameterstate As SqlParameter = New SqlParameter("@state",
SqlDbType.Char, 10)
parameterstate.Value = state
myCommand2.Parameters.Add(parameterstate)

Dim parameterzip As SqlParameter = New SqlParameter("@zip",
SqlDbType.NChar, 18)
parameterzip.Value = zip
myCommand2.Parameters.Add(parameterzip)

Dim parameterphone As SqlParameter = New SqlParameter("@phone",
SqlDbType.NChar, 18)
parameterphone.Value = phone
myCommand2.Parameters.Add(parameterphone)

Dim parameterbfname As SqlParameter = New
SqlParameter("@bfname", SqlDbType.NVarChar, 50)
parameterbfname.Value = bfname
myCommand2.Parameters.Add(parameterbfname)

Dim parameterblname As SqlParameter = New
SqlParameter("@blname", SqlDbType.NVarChar, 50)
parameterblname.Value = blname
myCommand2.Parameters.Add(parameterblname)

Dim parameterbadd1 As SqlParameter = New SqlParameter("@badd1",
SqlDbType.NVarChar, 50)
parameterbadd1.Value = badd1
myCommand2.Parameters.Add(parameterbadd1)

Dim parameterbadd2 As SqlParameter = New SqlParameter("@badd2",
SqlDbType.NVarChar, 50)
parameterbadd2.Value = badd2
myCommand2.Parameters.Add(parameterbadd2)

Dim parameterbcity As SqlParameter = New SqlParameter("@bcity",
SqlDbType.NVarChar, 50)
parameterbcity.Value = bcity
myCommand2.Parameters.Add(parameterbcity)

Dim parameterbstate As SqlParameter = New
SqlParameter("@bstate", SqlDbType.Char, 10)
parameterbstate.Value = bstate
myCommand2.Parameters.Add(parameterbstate)
'
Dim parameterbzip As SqlParameter = New SqlParameter("@bzip",
SqlDbType.NChar, 18)
parameterbzip.Value = bzip
myCommand2.Parameters.Add(parameterbzip)

Dim parameterbphone As SqlParameter = New
SqlParameter("@bphone", SqlDbType.NVarChar, 50)
parameterbphone.Value = bphone
myCommand2.Parameters.Add(parameterbphone)

' Open the connection and execute the Command
myConnection2.Open()
myCommand2.ExecuteNonQuery()
myConnection2.Close()

CODE IN ASPX PG

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim cart As Commerce.ShoppingCartDB = New Commerce.ShoppingCartDB()

' Calculate end-user's shopping cart ID
Dim cartId As String = cart.GetShoppingCartId()

' Calculate end-user's customerID
' Dim CustomerID As Integer = CInt(Request.Params("CustomerID"))
'Dim customerId As String = User.Identity.Name
' Update the address detail into customers record
' Dim orderadd As Commerce.OrdersDB = New Commerce.OrdersDB()

' Dim CustomerId As Integer = orderadd.PlaceOrderAdd(CustomerId,
fname.Text, lname.Text, add1.Text, add2.Text, city.Text, state.Text,
zip.Text, phone.Text, bfname.Text, blname.Text, badd1.Text, badd2.Text,
bcity.Text, bstate.Text, bzip.Text, bphone.Text)
UpdateCustomerDatabase()
Dim CustomerID As Integer = CInt(Request.Params("CustomerID"))
'Update labels to reflect the fact that the order has taken place
Header.Text = "Check Out Complete!"
'Message.Text = "<b>Your Order Number Is: </b>" & orderId
End Sub
Sub UpdateCustomerDatabase()

Dim Customer As Commerce.OrdersDB = New Commerce.OrdersDB()

' Obtain current user's Customer ID
Dim CustomerID As String = CInt(Request.Params("CustomerID"))

' Obtain references to row's controls
Dim fnametxt As TextBox = CType(FindControl("fname"), TextBox)
Dim lname As TextBox = CType(FindControl("lname"), TextBox)
Dim add1 As TextBox = CType(FindControl("add1"), TextBox)
Dim add2 As TextBox = CType(FindControl("add2"), TextBox)
Dim city As TextBox = CType(FindControl("city"), TextBox)
Dim state As TextBox = CType(FindControl("state"), TextBox)
Dim zip As TextBox = CType(FindControl("zip"), TextBox)
Dim phone As TextBox = CType(FindControl("phone"), TextBox)
Dim bfname As TextBox = CType(FindControl("bfname"), TextBox)
Dim blname As TextBox = CType(FindControl("blname"), TextBox)
Dim badd1 As TextBox = CType(FindControl("badd1"), TextBox)
Dim badd2 As TextBox = CType(FindControl("badd2"), TextBox)
Dim bcity As TextBox = CType(FindControl("bcity"), TextBox)
Dim bstate As TextBox = CType(FindControl("bstate"), TextBox)
Dim bzip As TextBox = CType(FindControl("bzip"), TextBox)
Dim bphone As TextBox = CType(FindControl("bphone"), TextBox)
Dim fname = fnametxt.Text

Customer.UpdateAdd(CInt(CustomerID), fname, lname.Text, add1.Text,
add2.Text, city.Text, state.Text, zip.Text, phone.Text, bfname.Text,
blname.Text, badd1.Text, badd2.Text, bcity.Text, bstate.Text, bzip.Text,
bphone.Text)

Response.Redirect("CheckOutpayment.aspx?CustomerID =" & CustomerID)

End Sub

--
t
Jul 21 '05 #1
2 1865
THIS IS THE PROBLEM DOES ANYONE KNOW HOW TO GET THE VALUES OUT OFTHE TEXTBOXES ON A PAGE THIS CODE IS NOT WORKING!!!!! I ampulling in the cusotmers old information into the textbox atpage load I want them to be able to make changes then update itbut it only passes the original text box values not the valuesat the time the update button is pushed help

Dim fnametxt As TextBox = CType(FindControl("fname"), TextBox)
Dim lname As TextBox = CType(FindControl("lname"), TextBox)
Dim add1 As TextBox = CType(FindControl("add1"), TextBox)
Dim add2 As TextBox = CType(FindControl("add2"), TextBox)
Dim city As TextBox = CType(FindControl("city"), TextBox)
Dim state As TextBox = CType(FindControl("state"), TextBox)
Dim zip As TextBox = CType(FindControl("zip"), TextBox)
Dim phone As TextBox = CType(FindControl("phone"), TextBox)
Dim bfname As TextBox = CType(FindControl("bfname"), TextBox)
Dim blname As TextBox = CType(FindControl("blname"), TextBox)
Dim badd1 As TextBox = CType(FindControl("badd1"), TextBox)
Dim badd2 As TextBox = CType(FindControl("badd2"), TextBox)
Dim bcity As TextBox = CType(FindControl("bcity"), TextBox)
Dim bstate As TextBox = CType(FindControl("bstate"), TextBox)
Dim bzip As TextBox = CType(FindControl("bzip"), TextBox)
Dim bphone As TextBox = CType(FindControl("bphone"), TextBox)
Dim fname = fnametxt.Text

User submitted from AEWNET (http://www.aewnet.com/)
Jul 21 '05 #2
THIS IS THE PROBLEM DOES ANYONE KNOW HOW TO GET THE VALUES OUT OFTHE TEXTBOXES ON A PAGE THIS CODE IS NOT WORKING!!!!! I ampulling in the cusotmers old information into the textbox atpage load I want them to be able to make changes then update itbut it only passes the original text box values not the valuesat the time the update button is pushed help

Dim fnametxt As TextBox = CType(FindControl("fname"), TextBox)
Dim lname As TextBox = CType(FindControl("lname"), TextBox)
Dim add1 As TextBox = CType(FindControl("add1"), TextBox)
Dim add2 As TextBox = CType(FindControl("add2"), TextBox)
Dim city As TextBox = CType(FindControl("city"), TextBox)
Dim state As TextBox = CType(FindControl("state"), TextBox)
Dim zip As TextBox = CType(FindControl("zip"), TextBox)
Dim phone As TextBox = CType(FindControl("phone"), TextBox)
Dim bfname As TextBox = CType(FindControl("bfname"), TextBox)
Dim blname As TextBox = CType(FindControl("blname"), TextBox)
Dim badd1 As TextBox = CType(FindControl("badd1"), TextBox)
Dim badd2 As TextBox = CType(FindControl("badd2"), TextBox)
Dim bcity As TextBox = CType(FindControl("bcity"), TextBox)
Dim bstate As TextBox = CType(FindControl("bstate"), TextBox)
Dim bzip As TextBox = CType(FindControl("bzip"), TextBox)
Dim bphone As TextBox = CType(FindControl("bphone"), TextBox)
Dim fname = fnametxt.Text

User submitted from AEWNET (http://www.aewnet.com/)
Jul 21 '05 #3

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

Similar topics

4
6110
by: shank | last post by:
Visually, the page will look somewhat like a spreadsheet. It could have hundreds of records (rows) displayed. I want to enable the user to edit any one or any number of records and any fields, then...
3
2132
by: Zlatko | last post by:
A question concerning Access Project with SQL Server: I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are...
15
7215
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? ...
2
3869
by: kennethgrice | last post by:
Hi, I am new to ASP.net and visual studio.net. I have created a new ASP.NET Web Application and have started with a simple form. I have created a simple test database that will store a...
1
282
by: Sporke13 | last post by:
I have used stored procedures to insert and select but for some reason I can not get this code to update records. Please help I must have made a dumb mistake STORED PROCEDURE CREATE Procedure...
6
5197
by: Greg P | last post by:
I am using VS2005 and have been learning a ton about databinding. I know that when you drag a view from the datasource window (creating a dataGridView) that an update method is not added to the...
30
3354
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
6
13290
by: Nano | last post by:
I want to update a MS Access Table using ASP, I have made the connection with the database but I am unable to update it. I am using the following code: ...
5
2245
by: Chris Cowles | last post by:
I use an application that uses Oracle 8.1.7. All functions of the application are completed with calls to stored procedures. A data entry error occurred that caused thousands of records to be...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7366
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
7471
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
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
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...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.