Jump to content
Sign in to follow this  
fibalous

asp.net SQL query

Recommended Posts

fibalous

Antes de mais boa tarde, tenho a seguinte query numa gridview:

SELECT aspnet_Users.UserName, tbl_projecto.nome_projecto, tbl_documentos.nome, tbl_documentos.path, tbl_documentos.nome_doc, tbl_documentos.data, tbl_documentos.ID_Doc

FROM aspnet_Users INNER JOIN tbl_documentos INNER JOIN tbl_projecto ON tbl_documentos.ID_projecto = tbl_projecto.ID_projecto INNER JOIN tbl_usersprojecto ON tbl_projecto.ID_projecto = tbl_usersprojecto.ID_projecto ON aspnet_Users.UserId = tbl_usersprojecto.UserID

ORDER BY tbl_documentos.data, tbl_documentos.nome

falta-me uma coisa, eu quero que o user que esteja logado no site só veja os ficheiros dos projectos a que ele está associado...alguém me sabe explicar como faço isso?

Obrigado desde já pelas respostas

PS: não sei se o tópico estará bem aqui ou se pertence à área de asp.net.

Share this post


Link to post
Share on other sites
fibalous

já está a funcionar fica algo assim do género:

SelectCommand="SELECT aspnet_Users.UserName, tbl_projecto.nome_projecto, tbl_documentos.nome, tbl_documentos.path, tbl_documentos.nome_doc, tbl_documentos.data, tbl_documentos.ID_Doc FROM aspnet_Users INNER JOIN tbl_documentos INNER JOIN tbl_projecto ON tbl_documentos.ID_projecto = tbl_projecto.ID_projecto INNER JOIN tbl_usersprojecto ON tbl_projecto.ID_projecto = tbl_usersprojecto.ID_projecto ON aspnet_Users.UserId = tbl_usersprojecto.UserID where aspnet_Users.UserName = @UserName ORDER BY tbl_documentos.data, tbl_documentos.nome"
            onselecting="SqlDataSource2_Selecting">
          <SelectParameters>
               <asp:parameter name="UserName" type="String" />
          </SelectParameters>  

protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        e.Command.Parameters[0].Value = this.User.Identity.Name;
    }

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.