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

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()

Once again sir, thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.