0

Hi there, I'm havin a session with value of ID. I need to create a query for GridView to show only values linked with user mentioned in session.
So my question is if theres any way how to modify my code which isnt working.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DbConnStr %>" 
        SelectCommand="SELECT [kod_reklamace], [cislo_rekl_zakazky], [kod_vyrobku], [stav], [reklamovane_mnozstvi], [jednotka], [pr], [tp], [tot], [r], [datum_pr_reklamace], [datum_pr_vzor], [no_odeslano_dne], [datum_uz_reklamace] FROM [reklamace] WHERE ([cislo_rekl_zakazky] = @cislo_rekl_zakazky)">
        <SelectParameters>
            <asp:SessionParameter Name="cislo_rekl_zakazky" SessionField="jmeno" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

Im using VB language and mine thoughts were like

identifikace = Session("jmeno")  
SqlDataSource.SelectCommand="Select ...... FROM [reklamace] WHERE ([cislo_rekl_zakazky]="<%identifikace%>")"

The problem is that I dont know how set up whole SqlDataSource by writing a code.

Could any of you help please? Thank you

Edited by Ycefire: n/a

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by Ycefire
0

You can simply fetch rows from the database with SqlDataAdapter object.

Dim Adp as New SqlDataAdapter("select * from tablename where col1='" & Session("id") & "'","put_connection_string")
Dim dt as new DataTable
 Adp.Fill(dt)

GridView1.DataSource = dt
GridView1.DataBind()
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.