Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 10th, 2007, 06:43 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with Select & Where statement

Hi

I am trying to get information in a Database to be displayed when a user is logged in using cookies. Unfortunately have seemed to have got stuck somewhere.

Please see the below code of where I have got to so far: -

<script runat="server">

Dim DBConnection As OleDbConnection
Dim DBCommand As OleDbCommand
Dim DBReader As OleDbDataReader
Dim SQLString As String
Dim UserNameCookie As HttpCookie

Sub Page_Load()

    If (Request.IsAuthenticated = true) Then
        pnlEdit.Visible = true
        pnlView.Visible = false
        lblStatus.Text = "<br>Welcome: " & _
        Request.Cookies("UserNameCookie").Value
       End If

    If Not Page.IsPostBack Then
    DBConnection = New OleDbConnection( _
      ConfigurationSettings.AppSettings("ConnectionStrin g"))
    DBConnection.Open()
    SQLString = "SELECT * FROM Customers" & _
        "WHERE CustomerEmail = '" & UserNameCookie & "'"
    DBCommand = New OleDbCommand(SQLString, DBConnection)
    DBReader = DBCommand.ExecuteReader()
    RepeaterDisplay.DataSource = DBReader
    RepeaterDisplay.DataBind()
    DBReader.Close()
    DBConnection.Close()
  End If

End Sub

I have declared the UserNameCookie as a HttpCookie but now getting an error on the page where Operator '&' is not defined for types 'String' and 'System.Web.HttpCookie'.

Does anyone have any suggestions or pointers of where I need to go from here?

Thanks

Sharon


  #2 (permalink)  
Old June 10th, 2007, 02:39 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You need to read the value from the cookie and place that into a string and then add that string to your SQL statement.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #3 (permalink)  
Old June 11th, 2007, 04:18 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks for the tip, becuase I am requesting the cookie value, I have now assigned it to the variable. For example:

Dim UserNameCookie As String
UserNameCookie = Request.Cookies("UserNameCookie").Value

Now I can use the variable UserNameCookie throughout my coding.

Thanks
Sharon


  #4 (permalink)  
Old June 11th, 2007, 07:09 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You are welcome, glad it worked out for you.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select statement ??? RinoDM SQL Server 2000 7 June 19th, 2008 08:40 AM
select Statement gregalb SQL Server 2000 3 January 15th, 2008 12:00 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Select Into statement ashu_from_india Oracle 8 October 9th, 2005 11:30 PM
Select statement Sarju Mehta SQL Server 2000 1 March 30th, 2004 03:16 PM



All times are GMT -4. The time now is 09:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.