session variable to registering

Results 1 to 2 of 2

Thread: session variable to registering

  1. #1
    Join Date
    Dec 1969

    Default session variable to registering

    i am trying to use a session variable as my primary id in my update statement and its not registering.<BR><BR>when i do this, this works:<BR>Sub Page_Load ( s As Object, e As EventArgs )<BR> username = session("username")<BR> user_id = session("user_id")<BR>response.write(user_id)<BR>E nd Sub<BR><BR>When I try to put it in my update stmt, it fails to read in this block.<BR><BR>Sub Submit_Update ( s As Object, e As EventArgs )<BR> <BR>Dim conn As OleDbConnection<BR>Dim str As String<BR>Dim cmd As OleDbCommand<BR><BR>user_id = session("user_id")<BR> <BR> conn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=c:websites
    laink emphomeshomes.mdb" )<BR><BR> str = "UPDATE [homes] SET [site_title]=@site_title, [intro_copy]=@intro_copy WHERE [user_id]=@user_id "<BR> cmd = New OleDbCommand( str, conn )<BR> cmd.Parameters.Add( "@site_title", site_title.Text )<BR> cmd.Parameters.Add( "@intro_copy", intro_copy.Text )<BR> cmd.Parameters.Add( "@user_id", user_id)<BR> <BR> cmd = New OleDbCommand( str, conn )<BR> <BR>conn.Open()<BR><BR> cmd.ExecuteNonQuery()<BR> <BR>conn.Close() <BR>End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: session variable to registering

    If you are using a querystring instead of a stored procedure, why are you using parameters? (I am used to just using stored procedures as that is best for performace).<BR><BR>If you are using a querystring, why not just do:<BR><BR>str = "UPDATE homes SET site_title=site_title.Text, intro_copy=intro_copy.Text WHERE user_id=session("user_id")<BR><BR>I am assuming all of these fields are in the homes table of your database?<BR><BR>Also, you did not declare user_id.<BR><BR>Hope this helps.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts