CONSULTA ENTRE TABELAS
Pessoal e o seguinte tenho a tabela cliente e tabela parcelasvencida estou fazendo a busca pela data de vencimento passando os
respectivo id para tabbela cliente buscando os cliente conforme os id passado
Private Sub CarregaVendas()
Dim dr As OleDbDataReader = Nothing
Using con As OleDbConnection = GetConnection()
Try
con.Open()
Dim sql As String = [Ô][Ô]
dtinicio = dtpInicio.Value.ToString
dtfim = dtpFim.Value.ToString
sql = [Ô]SELECT CodCliente, NomeCliente, ValorParc FROM tblVendasParceladas WHERE DateValue(DataVenc) < DateValue([ô][Ô] & dtinicio & [Ô][ô]) AND DateValue(DataVenc) < DateValue([ô][Ô] & dtfim & [Ô][ô])[Ô] [ô] AND (TIPO=[ô]A Prazo[ô]) ORDER BY ID[Ô]
Dim cmd As OleDbCommand = New OleDbCommand(sql, con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim dt As DataTable = New DataTable
da.Fill(dt)
dgvTodasVencidas.DataSource = dt
For i = 0 To dgvTodasVencidas.Rows.Count - 1
dgvTodasVencidas.CurrentCell = dgvTodasVencidas.Rows(i).Cells(0)
dgvTodasVencidas.CurrentRow.Cells(2).Value = dgvTodasVencidas.CurrentRow.Cells(2).Value
Dim sql1 As String = [Ô][Ô]
sql1 = [Ô]SELECT CodCliente, Nome, Devedor FROM tblCliente WHERE CodCliente=[Ô] & CInt(dgvTodasVencidas.CurrentRow.Cells(0).Value)
Dim cmd1 As OleDbCommand = New OleDbCommand(sql1, con)
Dim da1 As OleDbDataAdapter = New OleDbDataAdapter(cmd1)
Dim dt1 As DataTable = New DataTable
da1.Fill(dt1)
DataGridView1.DataSource = dt1
For p = 0 To DataGridView1.Rows.Count - 1
dgvTodasVencidas.CurrentRow.Cells(0).Value = DataGridView1.CurrentRow.Cells(0).Value
dgvTodasVencidas.CurrentRow.Cells(1).Value = DataGridView1.CurrentRow.Cells(1).Value
dgvTodasVencidas.CurrentRow.Cells(2).Value = dgvTodasVencidas.CurrentRow.Cells(2).Value
Next
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Using
End Sub
respectivo id para tabbela cliente buscando os cliente conforme os id passado
Private Sub CarregaVendas()
Dim dr As OleDbDataReader = Nothing
Using con As OleDbConnection = GetConnection()
Try
con.Open()
Dim sql As String = [Ô][Ô]
dtinicio = dtpInicio.Value.ToString
dtfim = dtpFim.Value.ToString
sql = [Ô]SELECT CodCliente, NomeCliente, ValorParc FROM tblVendasParceladas WHERE DateValue(DataVenc) < DateValue([ô][Ô] & dtinicio & [Ô][ô]) AND DateValue(DataVenc) < DateValue([ô][Ô] & dtfim & [Ô][ô])[Ô] [ô] AND (TIPO=[ô]A Prazo[ô]) ORDER BY ID[Ô]
Dim cmd As OleDbCommand = New OleDbCommand(sql, con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim dt As DataTable = New DataTable
da.Fill(dt)
dgvTodasVencidas.DataSource = dt
For i = 0 To dgvTodasVencidas.Rows.Count - 1
dgvTodasVencidas.CurrentCell = dgvTodasVencidas.Rows(i).Cells(0)
dgvTodasVencidas.CurrentRow.Cells(2).Value = dgvTodasVencidas.CurrentRow.Cells(2).Value
Dim sql1 As String = [Ô][Ô]
sql1 = [Ô]SELECT CodCliente, Nome, Devedor FROM tblCliente WHERE CodCliente=[Ô] & CInt(dgvTodasVencidas.CurrentRow.Cells(0).Value)
Dim cmd1 As OleDbCommand = New OleDbCommand(sql1, con)
Dim da1 As OleDbDataAdapter = New OleDbDataAdapter(cmd1)
Dim dt1 As DataTable = New DataTable
da1.Fill(dt1)
DataGridView1.DataSource = dt1
For p = 0 To DataGridView1.Rows.Count - 1
dgvTodasVencidas.CurrentRow.Cells(0).Value = DataGridView1.CurrentRow.Cells(0).Value
dgvTodasVencidas.CurrentRow.Cells(1).Value = DataGridView1.CurrentRow.Cells(1).Value
dgvTodasVencidas.CurrentRow.Cells(2).Value = dgvTodasVencidas.CurrentRow.Cells(2).Value
Next
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Using
End Sub
Qual a dúvida?
não esta listando os cliente com os ids que foi passado na primeira consulta
Sabe depurar? Se souber, coloque um break point na primeira linha e vai depurando pra ver se acha o que não está batendo.
Tópico encerrado , respostas não são mais permitidas