简体   繁体   中英

How to display selected value in datagrid?. vb 6

I'm trying to get the value of medicine that has a quantity of less than 15 and display it in datagrid.For example I have paracetamol that has quantity of 15 or less then the paracetamol will automatically display in the datagrid. I have a table name inventory with the field names MedicineName, Genericname, StockQuantity etc. My problem here is all the records in database display. Please help me. Thank you..

Here is my code in adodc connection Select StockQuantity from inventory


Private Sub Form_Load()
  Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\clinic.mdb" & ";Persist Security Info=False"
Adodc2.RecordSource = "select * from inventory order by StockQuantity asc"
Set DataGrid2.DataSource = Adodc2
Adodc2.Refresh

IF  StockQuantity <= 15 then Adodc2.Recordset(“StockQuantity”)
End If
End sub

If you need to filter your result, you can simply retrieve a filtered list, instead of fetching all data and add filter on datatable level.

You can simply modify your query;

Adodc2.RecordSource = "select * from inventory where StockQuantity < 15 order by StockQuantity asc"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM