Gridview + accessdatasource

Posted on 2011-04-28
Medium Priority
Last Modified: 2012-05-11
I have a gridview set up and im trying to run a connection string to it.

so at the moment i use
<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
                  DataFile="~/forums/forum.mdb" SelectCommand="SELECT * FROM [forum]">

Open in new window

But i want to use a where command to get: SELECT * FROM [forum] where Forum = "currentwebpage"

I get the current webpage via

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim s As String
        s = Request.QueryString("fn")
        Label1.Text = s
    End Sub

Open in new window

how can i do this in the code behind?
Question by:runnerjp2005
  • 4
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 35484426
Use a QueryString parameter

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
                  DataFile="~/forums/forum.mdb" SelectCommand="SELECT * FROM [forum] WHERE Forum=@forum">
          <asp:QueryStringParameter Name="forum" QueryStringField="fn" />

Author Comment

ID: 35484727
I used the above and it does not display the gridview at all
LVL 83

Expert Comment

ID: 35484755
And you are sure it should return some records for that forum name?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 35484807
yes attached is a screenshot of my db


Author Comment

ID: 35484837

Author Closing Comment

ID: 35484937
Played around with the code and got it 2 work :)

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question