Ir para conteúdo
Fórum Script Brasil
  • 0

Como enviar os dados da pesquisa para o datagrid


GILBERTO NOBRE

Pergunta

OLA, GOSTARIA DE SABER COMO ENVIAR OS DADOS DE UMA PESQUISA PARA UM DATAGRID. SEGUE O CÓDIGO DA PESQUISA ABAIXO

Private Function CodeSearch(xSearch As String) As Boolean

Dim Rs As ADODB.Recordset

Dim sql As String

Set Rs = New ADODB.Recordset

Rs.CursorLocation = adUseServer

sql = "select * from sb where cliente LIKE '" & xSearch & "%'"

Rs.Open sql, conn, adOpenStatic, adLockReadOnly, adCmdText

'Rs.Find "ProductID LIKE '" & xSearch & "*'"

If Rs.EOF = True Then

Rs.Close

Set Rs = Nothing

Exit Function

End If

If IsNull(Rs!cliente) Then

txtcliente.Text = ""

txtiecliente.Text = ""

cbomarca = ""

CodeSearch = False

Else

txtcliente.Text = Rs!cliente

txtiecliente.Text = Rs!End

cbomarca = Rs!ie

'Text3.Text = Format(rs!ProductPrice, "###,###,###,##0.00")

CodeSearch = True

End If

Rs.Close

Set Rs = Nothing

End Function

Private Function NameSearch(xSearch As String) As Boolean

Dim Rs As ADODB.Recordset

Dim sql As String

Set Rs = New ADODB.Recordset

Rs.CursorLocation = adUseServer

'sql = "select * from Stock"

sql = "select * from sb where cliente LIKE '" & xSearch & "%'"

Rs.Open sql, conn, adOpenStatic, adLockReadOnly, adCmdText

'Rs.Find "ProductName LIKE '" & xSearch & "*'"

If Rs.EOF = True Then

Rs.Close

Set Rs = Nothing

Exit Function

End If

If IsNull(Rs!cliente) Then

txtcliente.Text = ""

txtiecliente.Text = ""

cbomarca = ""

NameSearch = False

Else

txtcliente.Text = Rs!cliente

txtiecliente.Text = Rs!End

cbomarca = Rs!ie

'Text3.Text = Format(rs!ProductPrice, "###,###,###,##0.00")

NameSearch = True

End If

Rs.Close

Set Rs = Nothing

End Function

Private Sub txtcriterio_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If CodeSearch(txtcriterio) = False Then

NameSearch txtcriterio

End If

End If

End Sub

OBS: CASO alguém TIVER OUTRO CÓDIGO PARA PESQUISA EM BANCO MYSQL FAVOR ME DIZER!!!!

OBRIGADO

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

já tentou utilizar msflexgrid?

acho que ficaria bom..

>> adiciona no componentes "microsoft flexgrid control 6.0"

a sintaxe e o seguinte apos o select e a abertura da conection string fica +- assim

With MSFlexGrid1

.TextMatrix(1, 0) = rs!NOME

.TextMatrix(2, 1) = rs!rg

end with

rs.movenext

ai você pode fazer 1 do while algo do tipo para prencheer com todos os dados de todas as pesquisas assim:

MSFlexGrid1.Rows = 1

Do While Not rs.EOF

With MSFlexGrid1

.Rows = MSFlexGrid1.Rows + 1

.TextMatrix(.Rows - 1, 0) = rs!NOME

.TextMatrix(.Rows - 1, 1) = rs!rg

.TextMatrix(.Rows - 1, 2) = rs!CPF

.TextMatrix(.Rows - 1, 3) = rs!endereco

.TextMatrix(.Rows - 1, 4) = rs!Telefone

.TextMatrix(.Rows - 1, 5) = rs!Telefone2

End With

rs.MoveNext

Loop

qualquer duvida posta ai.

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...