Groups | Blog | Home
all groups > dotnet ado.net > october 2007 >

dotnet ado.net : How get current userid from SQL


VB Programmer
10/9/2007 1:53:41 PM
I have an SqlDataSource that I want to use for a gridview control.

I want to filter the SQL statement using the Userid GUID of the "current
user".

Any idea how to do this?

Thanks

Cor Ligthert[MVP]
10/10/2007 12:00:00 AM
As simple as you ask it is the answer you get.

Set it in your Select in the Where clause.

Nishant Rana
10/10/2007 1:24:00 AM
Hi,
I guess.This source code should help you.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CRMConnectionString %>"
ProviderName="<%$
ConnectionStrings:MSCRM_InterfaceConnectionString1.ProviderName %>"



SelectCommand="SELECT [opportunityid],
[opportunityratingcodename], [owneridname] FROM [FilteredOpportunity] WHERE
([opportunityid] = @opportunityid)" >
<selectparameters>
<asp:parameter
DefaultValue="e36ccb0f-cd44-dc11-8078-0010c6be7e4c"
Name="opportunityid" Type="String" />

<%--Inside the selectParameters you can specify other type of parameter as
well.
if you are getting the current user value from control than specify control
parameter
if you are getting the current user value from querystring than user
querystring parameter--%>
</selectparameters>
</asp:SqlDataSource>



<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1" BackColor="White"
BorderColor="#CCCCCC"
.................
</asp:GridView>


Regards,
VB Programmer
10/10/2007 8:32:20 PM
Thanks for the nice help Nishant!

[quoted text, click to view]

AddThis Social Bookmark Button