2
I’m trying to make an appointment at the bank and display it on a datagrid
, I have not so much experience, I do technical course and is my first question here, the code I am using is this:
Public Sub PreencheDataGrid(ByRef x As DataGridView, ByVal op1 As Integer, ByVal op2 As Integer)
Dim SDA As New MySqlDataAdapter
Dim bSource As New BindingSource
conectaBanco()
Dim query As String
query = "SELECT * FROM vw_tb_clientes"
objcmd = New MySqlCommand(query, con)
SDA.SelectCommand = objcmd
SDA.Fill(dbDataSet)
bSource.DataSource = dbDataSet
'Deixa o DataGridView limpo
x.DataSource = Nothing
x.DataSource = bSource
SDA.Update(dbDataSet)
fechaBanco()
End Sub
From what I understand with mine debug, the error is in the code SDA.Fill(dbDataSet)
, but I don’t know what’s happening since I have another datagridview
with almost the same code and functional, someone could help me?
I forgot to put the variable creations, they are outside the sub: Public objcmd As Mysqlcommand Public dbDataSet As Datatable That is, dbDataSet is a Datatable
– Matheus Menegatte
If using the
DataTable
, then missed theNew
. Note that in my example, with theDataSet
also needs.– Ismael
Now something else has happened, it is normally in datagridview, but the columns "Business Name" and "Fantasy Name" are bringing all the lines with the contents of the column title, I’m using the same code to filter only changes the query, that when you filter by name it looks like this: query = "SELECT 'Business Name', 'Name Fantasia', UF, Municipality, Neighborhood, Street, Complement, CEP, Branch FROM vw_tb_clients"
– Matheus Menegatte
If you use quotes, you will "create" a column with the value in quotes. First put the column name, then the description.
– Ismael
SELECT nome_empresarial 'Nome Empresarial', nome_fantasia 'Nome Fantasia', UF, Municipio, Bairro, Logradouro, Complemento, CEP, Filial FROM vw_tb_clientes
– Ismael
this I would have to modify in view?
– Matheus Menegatte
It worked @Matheusmenegatte?
– Ismael
Now it’s worked out, thank you very much.
– Matheus Menegatte