Show just one column Datagridview mysql vb.net -
i have database table schedule , has 7 columns (id, reserve_no, lastname, firstname, service, phonenumber, date_time) want show column date_time only.
here's code showing database on datagridview
dim dataadapter new mysqldataadapter dim datatable new datatable dim cmd new mysqlcommand mysqlconn.open() cmd .connection = mysqlconn .commandtext = "select * schedule" end dataadapter.selectcommand = cmd datatable.clear() dataadapter.fill(datatable) datagridview1.datasource = datatable mysqlconn.close()
selecting columns mysql table :
if not want see entire rows table, name columns in interested, separated commas.
change query select 1 column :
dim dataadapter new mysqldataadapter dim datatable new datatable dim cmd new mysqlcommand mysqlconn.open() cmd .connection = mysqlconn .commandtext = "select date_time schedule" end dataadapter.selectcommand = cmd datatable.clear() dataadapter.fill(datatable) datagridview1.datasource = datatable mysqlconn.close()
also can minimize output, retrieve each unique output record once adding keyword distinct.
Comments
Post a Comment