473,569 Members | 2,782 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(C onfigurationMan ager.AppSetting s("ConnectionSt ring"))
Dim myCommand2 As SqlCommand = New SqlCommand("Ord ersAddDetail",
myConnection2)

' Mark the Command as a SPROC
myCommand2.Comm andType = CommandType.Sto redProcedure

' Add Parameters to SPROC
Dim parameterCustom erID As SqlParameter = New
SqlParameter("@ CustomerID", SqlDbType.Int, 4)
parameterCustom erID.Value = CInt(customerID )
myCommand2.Para meters.Add(para meterCustomerID )

'Dim parameterOrderI D As SqlParameter = New
SqlParameter("@ OrderID", SqlDbType.Int, 4)
'parameterOrder ID.Direction = ParameterDirect ion.Output
'myCommand2.Par ameters.Add(par ameterOrderID)

Dim parameterfname As SqlParameter = New SqlParameter("@ fname",
SqlDbType.NVarC har, 50)
parameterfname. Value = fnametxt
myCommand2.Para meters.Add(para meterfname)

Dim parameterlname As SqlParameter = New
SqlParameter("@ lnametxt", SqlDbType.NVarC har, 50)
parameterlname. Value = lname
myCommand2.Para meters.Add(para meterlname)

Dim parameteradd1 As SqlParameter = New SqlParameter("@ add1",
SqlDbType.NVarC har, 50)
parameteradd1.V alue = add1
myCommand2.Para meters.Add(para meteradd1)

Dim parameteradd2 As SqlParameter = New SqlParameter("@ add2",
SqlDbType.NVarC har, 50)
parameteradd2.V alue = add2
myCommand2.Para meters.Add(para meteradd2)

Dim parametercity As SqlParameter = New SqlParameter("@ city",
SqlDbType.NVarC har, 50)
parametercity.V alue = city
myCommand2.Para meters.Add(para metercity)

Dim parameterstate As SqlParameter = New SqlParameter("@ state",
SqlDbType.Char, 10)
parameterstate. Value = state
myCommand2.Para meters.Add(para meterstate)

Dim parameterzip As SqlParameter = New SqlParameter("@ zip",
SqlDbType.NChar , 18)
parameterzip.Va lue = zip
myCommand2.Para meters.Add(para meterzip)

Dim parameterphone As SqlParameter = New SqlParameter("@ phone",
SqlDbType.NChar , 18)
parameterphone. Value = phone
myCommand2.Para meters.Add(para meterphone)

Dim parameterbfname As SqlParameter = New
SqlParameter("@ bfname", SqlDbType.NVarC har, 50)
parameterbfname .Value = bfname
myCommand2.Para meters.Add(para meterbfname)

Dim parameterblname As SqlParameter = New
SqlParameter("@ blname", SqlDbType.NVarC har, 50)
parameterblname .Value = blname
myCommand2.Para meters.Add(para meterblname)

Dim parameterbadd1 As SqlParameter = New SqlParameter("@ badd1",
SqlDbType.NVarC har, 50)
parameterbadd1. Value = badd1
myCommand2.Para meters.Add(para meterbadd1)

Dim parameterbadd2 As SqlParameter = New SqlParameter("@ badd2",
SqlDbType.NVarC har, 50)
parameterbadd2. Value = badd2
myCommand2.Para meters.Add(para meterbadd2)

Dim parameterbcity As SqlParameter = New SqlParameter("@ bcity",
SqlDbType.NVarC har, 50)
parameterbcity. Value = bcity
myCommand2.Para meters.Add(para meterbcity)

Dim parameterbstate As SqlParameter = New
SqlParameter("@ bstate", SqlDbType.Char, 10)
parameterbstate .Value = bstate
myCommand2.Para meters.Add(para meterbstate)
'
Dim parameterbzip As SqlParameter = New SqlParameter("@ bzip",
SqlDbType.NChar , 18)
parameterbzip.V alue = bzip
myCommand2.Para meters.Add(para meterbzip)

Dim parameterbphone As SqlParameter = New
SqlParameter("@ bphone", SqlDbType.NVarC har, 50)
parameterbphone .Value = bphone
myCommand2.Para meters.Add(para meterbphone)

' Open the connection and execute the Command
myConnection2.O pen()
myCommand2.Exec uteNonQuery()
myConnection2.C lose()

CODE IN ASPX PG

Protected Sub Button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s)
Dim cart As Commerce.Shoppi ngCartDB = New Commerce.Shoppi ngCartDB()

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

' Calculate end-user's customerID
' Dim CustomerID As Integer = CInt(Request.Pa rams("CustomerI D"))
'Dim customerId As String = User.Identity.N ame
' Update the address detail into customers record
' Dim orderadd As Commerce.Orders DB = New Commerce.Orders DB()

' Dim CustomerId As Integer = orderadd.PlaceO rderAdd(Custome rId,
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)
UpdateCustomerD atabase()
Dim CustomerID As Integer = CInt(Request.Pa rams("CustomerI D"))
'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 UpdateCustomerD atabase()

Dim Customer As Commerce.Orders DB = New Commerce.Orders DB()

' Obtain current user's Customer ID
Dim CustomerID As String = CInt(Request.Pa rams("CustomerI D"))

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

Customer.Update Add(CInt(Custom erID), 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.Redire ct("CheckOutpay ment.aspx?Custo merID=" & CustomerID)

End Sub

--
t
Jul 21 '05 #1
2 1871
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(FindContr ol("fname"), TextBox)
Dim lname As TextBox = CType(FindContr ol("lname"), TextBox)
Dim add1 As TextBox = CType(FindContr ol("add1"), TextBox)
Dim add2 As TextBox = CType(FindContr ol("add2"), TextBox)
Dim city As TextBox = CType(FindContr ol("city"), TextBox)
Dim state As TextBox = CType(FindContr ol("state"), TextBox)
Dim zip As TextBox = CType(FindContr ol("zip"), TextBox)
Dim phone As TextBox = CType(FindContr ol("phone"), TextBox)
Dim bfname As TextBox = CType(FindContr ol("bfname"), TextBox)
Dim blname As TextBox = CType(FindContr ol("blname"), TextBox)
Dim badd1 As TextBox = CType(FindContr ol("badd1"), TextBox)
Dim badd2 As TextBox = CType(FindContr ol("badd2"), TextBox)
Dim bcity As TextBox = CType(FindContr ol("bcity"), TextBox)
Dim bstate As TextBox = CType(FindContr ol("bstate"), TextBox)
Dim bzip As TextBox = CType(FindContr ol("bzip"), TextBox)
Dim bphone As TextBox = CType(FindContr ol("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(FindContr ol("fname"), TextBox)
Dim lname As TextBox = CType(FindContr ol("lname"), TextBox)
Dim add1 As TextBox = CType(FindContr ol("add1"), TextBox)
Dim add2 As TextBox = CType(FindContr ol("add2"), TextBox)
Dim city As TextBox = CType(FindContr ol("city"), TextBox)
Dim state As TextBox = CType(FindContr ol("state"), TextBox)
Dim zip As TextBox = CType(FindContr ol("zip"), TextBox)
Dim phone As TextBox = CType(FindContr ol("phone"), TextBox)
Dim bfname As TextBox = CType(FindContr ol("bfname"), TextBox)
Dim blname As TextBox = CType(FindContr ol("blname"), TextBox)
Dim badd1 As TextBox = CType(FindContr ol("badd1"), TextBox)
Dim badd2 As TextBox = CType(FindContr ol("badd2"), TextBox)
Dim bcity As TextBox = CType(FindContr ol("bcity"), TextBox)
Dim bstate As TextBox = CType(FindContr ol("bstate"), TextBox)
Dim bzip As TextBox = CType(FindContr ol("bzip"), TextBox)
Dim bphone As TextBox = CType(FindContr ol("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
6126
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 click a save button to UPDATE the SQL table. I'd like to use stored procedures if possible. How is this done? Where do I start? thanks
3
2134
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 stored procedures with input parameters by which they filter rows to be updated or inserted into other tables. Filtration is based on certain actual...
15
7221
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? Thank you.
2
3873
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 person's first and last name and their SSN. The primary key is an autonumbered field.
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 OrdersAddDetail ( @fname nvarchar(50), @lnametxt nvarchar(50), @add1 nvarchar(50), @add2 nvarchar(50),
6
5200
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 table adaptor. I would like to update the b ase tables thorugh the view. How do i do this? FYI: I have some reserarch on how to handle updating...
30
3365
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 commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on...
6
13299
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: ================================================================================== <%@Language = VBScript %> <% Option Explicit %> <%
5
2252
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 created with a consistent error in a single field. I can identify those easily records with a select statement. I'd *really* rather not have to change...
0
7697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2113
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 we have to send another system
0
937
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.