Update not working...

J

JJ297

After a user adds their name, address etc to a form and hit the submit
button an email is generated to go to someone to update the database.
This is what's being sent and works fine:

Dim ocdoEmail As New Object
ocdoEmail = Server.CreateObject("CDO.Message")
ocdoEmail.To = Session("GetEmail")
ocdoEmail.From = Session("GetEmail")
ocdoEmail.Subject = "Training Resource Material Request"
ocdoEmail.HTMLBody = "<a href=""http://seb2a54/traininglibrary/
FillRequest.aspx?RequestorID=" & x & """>Click link to fill out the
training library resource request</a>"
ocdoEmail.send()

After clicking on the hyperlink you are taken to FillRequest.aspx with
some of the info displayed in a details view and then two text boxes
are displayed so the user can update ship date, and due date.

My problem is the two text boxes are not being updated in the
database. Can someone assist me don't know what I'm missing.

Here's my stored procedure to update the info:

CREATE procedure updateloanerinfo

@requestorid int,
@shipdate datetime,
@duedate datetime


AS update LibraryRequest

set
[shipdate] = @shipdate,
[duedate] = @duedate

where requestorid = @requestorid
GO

Here's fillrequest.aspx.vb code behind:

Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LoanRequest.Click
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainUserConnectionString").ConnectionString)

'add string
Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "UpdateloanerInfo"
.Parameters.AddWithValue("@shipdate", ShipDateTxt.Text)
.Parameters.AddWithValue("@duedate", DueDateTxt.Text)


End With

Try
conn.Open()
cmd.ExecuteNonQuery()

Catch ex As Data.SqlClient.SqlException


Finally
conn.Dispose()
End Try


End Sub
 
P

Patrice

Hi,

IMHO you should never use an empty Catch clause. Remove this cloause so that
you( and us) can see the error message raised by the application rather than
guessing (hint : your sp have 3 parameters but you only define 2 parameters
in your code). Wihtout the catch clause you should have a message hinting at
this (or whaterver else error you could have)...
 
J

JJ297

Hi,

IMHO you should never use an empty Catch clause. Remove this cloause so that
you( and us) can see the error message raised by the application rather than
guessing (hint : your sp have 3 parameters but you only define 2 parameters
in your code). Wihtout the catch clause you should have a message hinting at
this (or whaterver else error you could have)...

--
Patrice

"JJ297" <[email protected]> a écrit dans le message de (e-mail address removed)...


After a user adds their name, address etc to a form and hit the submit
button an email is generated to go to someone to update the database.
This is what's being sent and works fine:
Dim ocdoEmail As New Object
ocdoEmail = Server.CreateObject("CDO.Message")
ocdoEmail.To = Session("GetEmail")
ocdoEmail.From = Session("GetEmail")
ocdoEmail.Subject = "Training Resource Material Request"
ocdoEmail.HTMLBody = "<a href=""http://seb2a54/traininglibrary/
FillRequest.aspx?RequestorID=" & x & """>Click link to fill out the
training library resource request</a>"
       ocdoEmail.send()
After clicking on the hyperlink you are taken to FillRequest.aspx with
some of the info displayed in a details view and then two text boxes
are displayed so the user can update ship date, and due date.
My problem is the two text boxes are not being updated in the
database.  Can someone assist me don't know what I'm missing.
Here's my stored procedure to update the info:
CREATE procedure updateloanerinfo
@requestorid int,
@shipdate datetime,
@duedate datetime
AS update LibraryRequest
set
[shipdate] = @shipdate,
[duedate] = @duedate
where requestorid = @requestorid
GO
Here's fillrequest.aspx.vb code behind:
Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LoanRequest.Click
       Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainU­serConnectionString").ConnectionString)
       'add string
       Dim cmd As New Data.SqlClient.SqlCommand
       With cmd
           .Connection = conn 'the connection
           .CommandType = Data.CommandType.StoredProcedure
           .CommandText = "UpdateloanerInfo"
           .Parameters.AddWithValue("@shipdate", ShipDateTxt..Text)
           .Parameters.AddWithValue("@duedate", DueDateTxt.Text)
       End With
       Try
                      conn.Open()
           cmd.ExecuteNonQuery()
       Catch ex As Data.SqlClient.SqlException
       Finally
           conn.Dispose()
       End Try
  End Sub- Hide quoted text -

- Show quoted text -

Thanks Patrice,

I added the 3rd parameter and it's now working.
 
J

JJ297

Hi,

IMHO you should never use an empty Catch clause. Remove this cloause so that
you( and us) can see the error message raised by the application rather than
guessing (hint : your sp have 3 parameters but you only define 2 parameters
in your code). Wihtout the catch clause you should have a message hinting at
this (or whaterver else error you could have)...

--
Patrice

"JJ297" <[email protected]> a écrit dans le message de (e-mail address removed)...


After a user adds their name, address etc to a form and hit the submit
button an email is generated to go to someone to update the database.
This is what's being sent and works fine:
Dim ocdoEmail As New Object
ocdoEmail = Server.CreateObject("CDO.Message")
ocdoEmail.To = Session("GetEmail")
ocdoEmail.From = Session("GetEmail")
ocdoEmail.Subject = "Training Resource Material Request"
ocdoEmail.HTMLBody = "<a href=""http://seb2a54/traininglibrary/
FillRequest.aspx?RequestorID=" & x & """>Click link to fill out the
training library resource request</a>"
       ocdoEmail.send()
After clicking on the hyperlink you are taken to FillRequest.aspx with
some of the info displayed in a details view and then two text boxes
are displayed so the user can update ship date, and due date.
My problem is the two text boxes are not being updated in the
database.  Can someone assist me don't know what I'm missing.
Here's my stored procedure to update the info:
CREATE procedure updateloanerinfo
@requestorid int,
@shipdate datetime,
@duedate datetime
AS update LibraryRequest
set
[shipdate] = @shipdate,
[duedate] = @duedate
where requestorid = @requestorid
GO
Here's fillrequest.aspx.vb code behind:
Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LoanRequest.Click
       Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TrainU­serConnectionString").ConnectionString)
       'add string
       Dim cmd As New Data.SqlClient.SqlCommand
       With cmd
           .Connection = conn 'the connection
           .CommandType = Data.CommandType.StoredProcedure
           .CommandText = "UpdateloanerInfo"
           .Parameters.AddWithValue("@shipdate", ShipDateTxt..Text)
           .Parameters.AddWithValue("@duedate", DueDateTxt.Text)
       End With
       Try
                      conn.Open()
           cmd.ExecuteNonQuery()
       Catch ex As Data.SqlClient.SqlException
       Finally
           conn.Dispose()
       End Try
  End Sub- Hide quoted text -

- Show quoted text -

Thanks for telling me also to never use an empty try catch clause too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top