M
Me LK
I have a page that will allow a user to add new data to a database the
first time they view the page and then allows them to return to add
more data or to update existing data. The initial adding of the data
works fine and all data added to first time the user sees the document
is put into the database. The update doesn't work, however. There is
no error. The page redirects as it is supposed to but there is no new
data.
VB 1.1
code behind
_____________________________________________________________________
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
' Create Instance of Connection and Command Object
'State.SelectedIndex = 0
Dim connection1 As New SqlConnection(connectionString)
Dim Command1 As New SqlCommand("UpdateAddress", connection1)
Command1.CommandType = CommandType.StoredProcedure
Command1.Parameters.Add("@CustomerID",
Context.Session("CustomerID"))
Command1.Parameters.Add("@first", txtFName.Text)
Command1.Parameters.Add("@Last", txtLastName.Text)
Command1.Parameters.Add("@Address1", txtStreetAddress.Text)
Command1.Parameters.Add("@Address2", txtStreetAddress2.Text)
Command1.Parameters.Add("@City", txtCity.Text)
Command1.Parameters.Add("@State", State.DataValueField)
Command1.Parameters.Add("@Zip", txtZip.Text)
Command1.Parameters.Add("@phone", txtPhone.Text)
' update address
connection1.Open()
Command1.ExecuteNonQuery()
connection1.Close()
_______________________________________________________________________
Stored proceedure
(@CustomerID int,
@First varchar (50),
@Last varchar (50),
@Address1 varChar (100),
@Address2 varChar (100),
@City varChar (100),
@State varChar (50),
@Zip varChar (50),
@Phone varChar (50)
)
as
Update tblCustomers
SET [first] = @first, [last] = @last, HomeAddress = @Address1,
HomeAddress2 = @Address2, City = @city,
@State = state, @Zip = Zip, @Phone = phone
Where CustomerID= @CustomerID
_____________________________________________________
The same code is used for the initial addition of data as well as the
update. Initial works fine but update does not.
Any suggestions?
first time they view the page and then allows them to return to add
more data or to update existing data. The initial adding of the data
works fine and all data added to first time the user sees the document
is put into the database. The update doesn't work, however. There is
no error. The page redirects as it is supposed to but there is no new
data.
VB 1.1
code behind
_____________________________________________________________________
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
' Create Instance of Connection and Command Object
'State.SelectedIndex = 0
Dim connection1 As New SqlConnection(connectionString)
Dim Command1 As New SqlCommand("UpdateAddress", connection1)
Command1.CommandType = CommandType.StoredProcedure
Command1.Parameters.Add("@CustomerID",
Context.Session("CustomerID"))
Command1.Parameters.Add("@first", txtFName.Text)
Command1.Parameters.Add("@Last", txtLastName.Text)
Command1.Parameters.Add("@Address1", txtStreetAddress.Text)
Command1.Parameters.Add("@Address2", txtStreetAddress2.Text)
Command1.Parameters.Add("@City", txtCity.Text)
Command1.Parameters.Add("@State", State.DataValueField)
Command1.Parameters.Add("@Zip", txtZip.Text)
Command1.Parameters.Add("@phone", txtPhone.Text)
' update address
connection1.Open()
Command1.ExecuteNonQuery()
connection1.Close()
_______________________________________________________________________
Stored proceedure
(@CustomerID int,
@First varchar (50),
@Last varchar (50),
@Address1 varChar (100),
@Address2 varChar (100),
@City varChar (100),
@State varChar (50),
@Zip varChar (50),
@Phone varChar (50)
)
as
Update tblCustomers
SET [first] = @first, [last] = @last, HomeAddress = @Address1,
HomeAddress2 = @Address2, City = @city,
@State = state, @Zip = Zip, @Phone = phone
Where CustomerID= @CustomerID
_____________________________________________________
The same code is used for the initial addition of data as well as the
update. Initial works fine but update does not.
Any suggestions?