Sending email... incorrect value(parameter) comes back



The user selects an item from the gridview which takes them to
checkoutitem.aspx (this works well)

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Response.Redirect("checkoutItem.aspx?TitleID=" &

End Sub

I'm able to fill out the form then the email is sent. I get the email
but the correct titleid is not there.

Protected Sub Submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Submit.Click

Dim PhoneNum As String = PhNoTxt.Text

Dim Job As String = JobTxt.Text

Dim StreetAddress1 As String = Street1Txt.Text

Dim StreetAddress2 As String = Street2Txt.Text

Dim City As String = CityTxt.Text

Dim State As String = StateTxt.Text

Dim Zip As String = ZipcodeTxt.Text

Dim ZipPlus As String = ZipPlusTxt.Text

Dim conn As New

Dim cmd As New Data.SqlClient.SqlCommand

With cmd

..Connection = conn 'the connection

..CommandType = Data.CommandType.StoredProcedure

..CommandText = "AddLoanRequest"

..Parameters.AddWithValue("@RequestorEmail", EmailAdd.Text)

..Parameters.AddWithValue("@RequestDate", LoanDate.Text)

..Parameters.AddWithValue("@FName", FName.Text)

..Parameters.AddWithValue("@LName", LName.Text)

..Parameters.AddWithValue("@PhoneNum", PhNoTxt.Text)

..Parameters.AddWithValue("@JobTitleID", JobTxt.Text)

..Parameters.AddWithValue("@StreetAddress1", Street1Txt.Text)

..Parameters.AddWithValue("@StreetAddress2", Street2Txt.Text)

..Parameters.AddWithValue("@City", CityTxt.Text)

..Parameters.AddWithValue("@State", StateTxt.Text)

..Parameters.AddWithValue("@Zip", ZipcodeTxt.Text)

..Parameters.AddWithValue("@ZipPlus4", ZipPlusTxt.Text)

End With



Dim x As Integer

x = cmd.ExecuteNonQuery

Dim ocdoEmail As New Object

ocdoEmail = Server.CreateObject("CDO.Message")

ocdoEmail.To = Session("GetEmail")

ocdoEmail.From = Session("GetEmail")


ocdoEmail.Subject = "Training Library Request"

ocdoEmail.HTMLBody = "<a href=""
traininglibrary/Fillrequest.aspx?TitleID=" & x & """>Click to view </



End Sub

Here's the stored procedure AddLoanRequest

CREATE procedure AddLoanRequest
@RequestorEmail varchar (75),
@RequestDate datetime,
@Fname varchar (50),
@Lname varchar (50),
@PhoneNum char (10),
@JobTitleID int,
@StreetAddress1 varchar (50),
@StreetAddress2 varchar (50),
@City varchar (50),
@State char (2),
@Zip char (5),
@ZipPlus4 char (4)

set NOCOUNT on
declare @TitleID int

insert into Requestors(RequestorEmail, Titleid,RequestDate,
set @titleid = SCOPE_IDENTITY() --grabbing the id

select @titleid as titleid --return to caller for email


Is the ocdoEmail.HTMLBody correct? Do I need to put something on

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

Similar Threads

Question about... 2
Need help with code... 10