Request.querystring problem

Discussion in 'ASP .Net' started by JJ297, Aug 20, 2007.

  1. JJ297

    JJ297 Guest

    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, Aug 20, 2007
    #1
    1. Advertising

  2. JJ297

    JJ297 Guest

    On Aug 20, 3:14 pm, JJ297 <> 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.
    JJ297, Aug 20, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Bass
    Replies:
    2
    Views:
    3,700
    dave wanta
    Jul 4, 2003
  2. George
    Replies:
    5
    Views:
    6,594
    George
    Apr 2, 2004
  3. michaaal
    Replies:
    6
    Views:
    399
    Michael D. Kersey
    Jul 15, 2003
  4. John Davis
    Replies:
    2
    Views:
    375
    Dave Anderson
    Aug 18, 2003
  5. Ivan
    Replies:
    5
    Views:
    151
Loading...

Share This Page