Home > Back-end >  TDBGrid consult
TDBGrid consult

Time:10-23

When using BCB6.0 write a reading data from a mysql database table, shown in the DBGrid. But wanted to do some to mysql database for data processing, put them in the DBGrid. Detailed description and questions as follows:

DBGrid, DataSource, ADOQuery ADOConnection four form to get data from a mysql database product_info table. Product_info access to the field for the name, price, dicount, type. Now there are two problems, can't solve.

Problem a:
From the product_info tables has a value of "goods 1100,0.8, 1". I added in the DBGrid six Cloumns. Respectively 0-5.
AnsiString goods a=1;
AnsiString b=100;
AnsiString c=0.8;
AnsiString d=1;
According to the rules of the above data was processed, the abcd numerical changed respectively, and derived the e, f two variable values. Now
Want to send a, b, c, d, e, f six variables respectively assign values to the DBGrid six Cloumn. Namely to achieve in the DBGrid show the value of abcdef.
Can you tell me should achieve the following?

Question 2:
Make from the product_info table records, is a multiple records. Each record will handle, and then in the DBGrid. Then after DBGrid into a list of values, (1) how to continue to add data to the second line?
(2) if you want to automatically generate sequence Numbers, how to do?

Question 3:
Assumes that the operation process, there are 10 data. To achieve which line, click with the mouse to click on the right you can delete the record, and automatic sequence Numbers, should how to implement,


Thank you.

CodePudding user response:

Question just a little, you don't the rules of the complex, a computed columns, can deal with
Question 3: query - & gt; The Delete (); Is to delete the current line
Remove after the completion of the first. Next. Eof... Traverse again it is ok to deal with the


CodePudding user response:

If too complicated, made transformation clientdataset, create virtual columns, crestor can solve the,

CodePudding user response:

1. Are you a batch data. Why don't you just calculate according to the rules in the SQL and remove to directly show? Can you use the program for the calculation of general SQL also can finish. Really not line, inside the OnEndRowEdit events for processing.
2. Are you bind data-aware controls. This new, completely don't have to worry about you. How many records will show how many bars. Without the need to increase human.
3. ADO a RecNo. According to the current line number. This value is used as a serial number. After deleting records to refresh the ADO.
4. Use the data of perception. Add a right-click menu controls, direct ado - & gt; Delete () to delete the current line.

  • Related