Request.querystring problem

J

JJ297

I have a generated email going to another person after they submit a
question. When you click on the email sent to the user it's not
getting the question ID. What am I doing wrong?

Here's the code behind page:


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim question As String = Txtquestion.Text

Dim conn As New Data.SqlClient.SqlConnection("Data
Source=seb2a54;Initial Catalog=EDCSFAQS;Persist Security
Info=True;User ID=EDCSFAQUser;Password=fax") 'this is the conn from
frontpage


Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "AddQuestion"
.Parameters.AddWithValue("@topicid",
CInt(DropDownList1.SelectedItem.Value))
.Parameters.AddWithValue("@quesdate", QuesDate.Text)
.Parameters.AddWithValue("@questions", Txtquestion.Text)
.Parameters.AddWithValue("@FName", FName.Text)
.Parameters.AddWithValue("@LName", LName.Text)
.Parameters.AddWithValue("@EmailAdd", EmailAdd.Text)

End With
conn.Open()

Dim x As Integer
x = cmd.ExecuteScalar 'will bring back my quesID for the email


lbloutcome.Text = "Your entry was submitted into the
database."


Dim ocdoEmail As New Object
ocdoEmail = Server.CreateObject("CDO.Message")
ocdoEmail.To = Session("GetEmail")
ocdoEmail.From = Session("GetEmail")
ocdoEmail.Subject = "EDCS Question"
ocdoEmail.HTMLBody = "<a href=""http://seb2a54/cdpedcsfaqs/
cdpadminEditpage.aspx?quesid=" & x & """> Click to view question that
was submitted.</a>"

ocdoEmail.send()

conn.Close()


End Sub


Here's the stored procedure I'm using.

CREATE procedure AddQuestion
@quesdate datetime,
@topicid int,
@questions varchar(1000) ,
@fname varchar (50),
@lname varchar (50),
@emailadd varchar (250)
AS
Set NOCOUNT ON
declare @quesid int


INSERT INTO QuesNAns(quesdate,topicid, questions)
values(@quesdate,
@topicid,
@questions)


set @quesid = SCOPE_IDENTITY()


INSERT INTO Requesters(quesid,fname,lname,emailadd)
values(@quesid,
@fname,
@lname,
@emailadd)

return @quesid
GO
 
J

JJ297

I have a generated email going to another person after they submit a
question. When you click on the email sent to the user it's not
getting the question ID. What am I doing wrong?

Here's the code behind page:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim question As String = Txtquestion.Text

Dim conn As New Data.SqlClient.SqlConnection("Data
Source=seb2a54;Initial Catalog=EDCSFAQS;Persist Security
Info=True;User ID=EDCSFAQUser;Password=fax") 'this is the conn from
frontpage

Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "AddQuestion"
.Parameters.AddWithValue("@topicid",
CInt(DropDownList1.SelectedItem.Value))
.Parameters.AddWithValue("@quesdate", QuesDate.Text)
.Parameters.AddWithValue("@questions", Txtquestion.Text)
.Parameters.AddWithValue("@FName", FName.Text)
.Parameters.AddWithValue("@LName", LName.Text)
.Parameters.AddWithValue("@EmailAdd", EmailAdd.Text)

End With
conn.Open()

Dim x As Integer
x = cmd.ExecuteScalar 'will bring back my quesID for the email

lbloutcome.Text = "Your entry was submitted into the
database."

Dim ocdoEmail As New Object
ocdoEmail = Server.CreateObject("CDO.Message")
ocdoEmail.To = Session("GetEmail")
ocdoEmail.From = Session("GetEmail")
ocdoEmail.Subject = "EDCS Question"
ocdoEmail.HTMLBody = "<a href=""http://seb2a54/cdpedcsfaqs/
cdpadminEditpage.aspx?quesid=" & x & """> Click to view question that
was submitted.</a>"

ocdoEmail.send()

conn.Close()

End Sub

Here's the stored procedure I'm using.

CREATE procedure AddQuestion
@quesdate datetime,
@topicid int,
@questions varchar(1000) ,
@fname varchar (50),
@lname varchar (50),
@emailadd varchar (250)
AS
Set NOCOUNT ON
declare @quesid int

INSERT INTO QuesNAns(quesdate,topicid, questions)
values(@quesdate,
@topicid,
@questions)

set @quesid = SCOPE_IDENTITY()

INSERT INTO Requesters(quesid,fname,lname,emailadd)
values(@quesid,
@fname,
@lname,
@emailadd)

return @quesid
GO

I was missing:

select @quesid as quesid -- return to caller if needed

All set now.
 

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


Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top