How get current userid from SQL

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

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
 
As simple as you ask it is the answer you get.

Set it in your Select in the Where clause.

Cor
 
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,
Nishant Rana
 
Back
Top