Maximum number of tables: Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiBase/html/delphi_20061210224437206.html
Why is there no value I found out...
Paste your statement, OK?
Query3. SQL. Add ('select max (ID) as maxid from userload ');
Query3.open;
T: = query3.fieldvalues ['maxid'];
This is the key part, and I assign a value to other variables, which means that I am a null value... however, when there is a record in the table, there will be no error. If there is no record, there will be an error ~
Query3. SQL. Add ('select max (ID) as maxid from userload ');
Query3.open;
If not query3. SQL. Empty then
T: = query3.fieldvalues ['maxid'];
This will not solve the essential problems ~ If no records exist in the table ~ No or wrong !?
VaR
A, B: string;
B: = formatdatetime ('yyyymmdd', date );
Query5. SQL. Add ('select max (docid) as maxid from doctor ');
Query5. SQL. Add ('where docid like: docid ');
Query5.parambyname ('docid'). asstring: = S + '% ';
Query5.open;
A: = query5.fieldbyname ('maxid'). asstring;
If a = ''then
B: = B + '1'
Else
Begin
B: = B + inttostr (strtoint (TRIM (A) + 1 );
System. Delete (B, 1, 2 );
Doctor. append;
Doctor. Fields [0]. asstring: = B;
I changed it to this now. How can I add the first and the second is wrong?
If no record exists in the table, the query result is null. You can judge this as follows,
If query3.fieldbyname ('maxid') = ''then // no records exist in the table
//
Else
//
I solved it myself ~ It is because I directly add the maximum number after extracting the current time and then cut the field, resulting in repeated primary key ~
Thank you!
Close the post ~~ Really ~