Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET SQL VB.NET Server
hello,
 
I have the same probleme since monday...
I'm looking for filtering my SQL's columns user field from the current windows's userid .
 
I followed some explaination but nothing works i let you see my code:
 
in my ASP page I would test with a short query:
 
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:LabAccManConnectionString %>"
    selectcommand="SELECT * FROM [account_user] WHERE [genacc_user_adacc] = @genacc_user_adacc">
    <selectparameters>
        <asp:parameter name="genacc_user_adacc" type="String" />
    </selectparameters>
</asp:sqldatasource>
 

when i put 'hermans5' instead of @genacc_user_adacc it works it displays one line properly into my grid view
 
may be it come from the "code behind":
 
Imports System.Text.RegularExpressions
Imports System
 

Partial Class userpage
    Inherits System.Web.UI.Page
    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
        e.Command.Parameters("@genacc_user_adacc").Value = Me.User.Identity.Name
    End Sub
End Class
 

 
Thanks you in advance, this problem makes me crazy it don't understand at all Frown | :(
 
Thanks
 
Best Regards
 

Samuel
Posted 5-May-10 21:38pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Dim name As String = User.Identity.Name.Split("\"c)(1) before e.Command.Parameters("@genacc_user_adacc").Value = name
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 490
1 Maciej Los 299
2 BillWoodruff 174
3 /\jmot 170
4 Suraj Sahoo | Coding Passion 150
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 6 May 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100