?
Solved

Gridview + accessdatasource

Posted on 2011-04-28
6
Medium Priority
?
340 Views
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]">
              </asp:AccessDataSource>

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?
0
Comment
Question by:runnerjp2005
  • 4
  • 2
6 Comments
 
LVL 83

Accepted Solution

by:
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">
        <SelectParameters>
          <asp:QueryStringParameter Name="forum" QueryStringField="fn" />
        </SelectParameters>
              </asp:AccessDataSource>
0
 

Author Comment

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

Expert Comment

by:CodeCruiser
ID: 35484755
And you are sure it should return some records for that forum name?
0
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

by:runnerjp2005
ID: 35484807
yes attached is a screenshot of my db


untitled.bmp
0
 

Author Comment

by:runnerjp2005
ID: 35484837
0
 

Author Closing Comment

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

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