Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Private Sub FillTarefasGeral(ByVal Proc As Integer)

        MsgBox(Proc)

        Dim table As New DataTable

        Access.AddParam("@Tipo", Proc)

        Access.ExecQuery(" Select Tarefas.Id_Tarefa, Tarefas.Tarefa, Links.ID_Link As Calendar, Links.Site As Calendario, Links.Path As Link, " &
                         " Tarefas_Proc.ID, Tarefas_Proc.Tar_Título, Tarefas_Proc.Prioridade, Tarefas_Proc.[Concluída] As P_Concluida, " &
                         " Tarefas_Proc.[Data de Conclusão], SubTarefas.ID, SubTarefas.Título, SubTarefas.Prioridade, SubTarefas.[Concluída], " &
                         " SubTarefas.[Data de Conclusão], Documentos.ID_Doc As Documento, Documentos.Documento As NomeDoc, Documentos.Processo as Processo " &
                         " FROM (Links INNER JOIN Tarefas On Links.ID_Link = Tarefas.Calendar) " &
                         " INNER Join(Tarefas_Proc INNER JOIN (Documentos INNER JOIN SubTarefas On Documentos.ID_Doc = SubTarefas.Documento) " &
                         " On Tarefas_Proc.ID = SubTarefas.Tar_Origin) On Tarefas.Id_Tarefa = Tarefas_Proc.PTarefa " &
                         " Where (Documentos.Processo =" & Proc & ")")


        If NotEmpty(Access.Exception) Then MsgBox(Access.Exception) : Exit Sub


        ' Create four typed columns in the DataTable.
        table.Columns.Add("Id_Tarefa", GetType(Integer))
        table.Columns.Add("Tarefa", GetType(String))
        table.Columns.Add("Calendar", GetType(Integer))
        table.Columns.Add("Calendario", GetType(String))
        table.Columns.Add("Link", GetType(String))
        table.Columns.Add("Proc_ID", GetType(Integer))
        table.Columns.Add("Tar_Título", GetType(String))
        table.Columns.Add("Prioridade", GetType(String))
        table.Columns.Add("P_%Conclida", GetType(Double))
        table.Columns.Add("P_DataConclusão", GetType(DateTime))
        table.Columns.Add("ID_SubTar", GetType(Integer))
        table.Columns.Add("ST_Título", GetType(String))
        table.Columns.Add("ST_Prioridade", GetType(String))
        table.Columns.Add("ST_%Conclida", GetType(Double))
        table.Columns.Add("ST_DataConclusão", GetType(DateTime))
        table.Columns.Add("Documento", GetType(Integer))
        table.Columns.Add("NomeDoc", GetType(String))
        table.Columns.Add("Processo", GetType(Integer))


        For Each R As DataRow In Access.DBDT.Rows
            table.Rows.Add((R("Id_Tarefa")), (R("Tarefa")), (R("Calendar")), (R("Calendario")), (R("Link")), (R("Tarefas_Proc.ID")), (R("Tar_Título")), (R("Tarefas_Proc.Prioridade")), (R("P%Concluída]")), (R("Tarefas_Proc.[Data de Conclusão]")), (R("SubTarefas.ID,")), (R("SubTarefas.Título")), (R("SubTarefas.[% Concluída]")), (R("SubTarefas.[Data de Conclusão]")), (R("Documento")), (R("NomeDoc")), (R("Processo")))

        Next
        TarefasGeralDataGridView.DataSource = table

    End Sub


What I have tried:

everything i know. I Get a msg telling that some parameters have not value. Thanks in advance.
Posted
Updated 30-Jul-19 9:14am
v2

1 solution

As far as I can see, the names of the columns do not match.
For example, in your query you have
SQL
select .... Tarefas_Proc.ID, ....

and in the later code you try to reference it with
VB
... (R("Tarefas_Proc.ID")),..

Table aliases are never included in column names in a result set so the correct way to reference the column would be
VB
... (R("ID")),..

Of course you can define column specific aliases if needed, just like you have done with some pof the columns
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900