Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Request.querystring problem (http://www.velocityreviews.com/forums/t531107-request-querystring-problem.html)

JJ297 08-20-2007 07:14 PM

Request.querystring problem
 
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


JJ297 08-20-2007 07:23 PM

Re: Request.querystring problem
 
On Aug 20, 3:14 pm, JJ297 <nc...@yahoo.com> wrote:
> 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.



All times are GMT. The time now is 06:16 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.