Home > Back-end >  Read the database to the last row number, the result always is zero, please advice?
Read the database to the last row number, the result always is zero, please advice?

Time:09-24


If the database for *. MDB
Table1 - & gt; Post ();
Int a=Table1 - & gt; FieldByName (" Id ") - & gt; AsInteger;
The results of a=29;

I now want to transposition paradox
Database for *. DB, database pictured above

Table1 - & gt; The Last ().
Table1 - & gt; The Prior ();
Int a=Table1 - & gt; FieldByName (" Id ") - & gt; AsInteger;
The results of a=28;

Table1 - & gt; The Last ().
Int a=Table1 - & gt; FieldByName (" Id ") - & gt; AsInteger;
The results of a=0;

Table1 - & gt; Post ();
Int a=Table1 - & gt; FieldByName (" Id ") - & gt; AsInteger;
The results of a=0;

Table1 - & gt; Post ();
Table1 - & gt; The Prior ();
Int a=Table1 - & gt; FieldByName (" Id ") - & gt; AsInteger;
The results of a=28;

I actually want to read the last row number, namely 29.
But the pointer to the last row results when the total of 0;
Have a master can tell what's the problem?

CodePudding user response:

Add: the paradox of id is on the field
2 to 19 to 26 middle discontinuous is I delete, I am using the variable

CodePudding user response:

I first Table1 - & gt; Insert (); After the edit box input values, after call Table1 - & gt; Post (); To save, and then the Table1 - & gt; Fields - & gt; FieldByNumber (1) - & gt; AsInteger; Take out the results of
As long as you don't check the last line, check what problem have no other line, the last line out, is 0, to add numerical check, the penultimate line the last normal behavior 0; Add a check, the penultimate line normal last line is 0;

If does not perform Table1 - & gt; Insert (); Check the last line of the results is normal,

CodePudding user response:

Is not a Post again, and then read the Prior data, or don't auto-increment id, artificial maintenance id, so you don't have to turn back to read id value

CodePudding user response:

Read write to all on my own computer, the installation of my application to the other machines (don't BCB) can also be read write *. DB database, but is finally popped up a

[Microsoft] [ODBC driver manager] did not find the data source name and did not specify a default driver dialog

Is not on your own computer,

I'm in the ODBC data source "manager", set the DSN is used to connect to database system DSN, not user DSN so not this reason,

Someone had a similar problem?

CodePudding user response:

In fact for the application of the data is very convenient to use Sqlite, it is not necessary to use the access, paradox of such file database

CodePudding user response:

This problem might be too strange, no one know, give up, I have a new problem again or you so scattered out too unworthy, I want to in the text TXT file, the output line of characters after 1234 line feeds, and output a line of characters abcdef line feeds, and output a line of characters "statistical results  " after the line, but the result is always appear black spots,

CodePudding user response:

Int hfile;
AnsiString s="1234 \ r";
AnsiString s1="abcdef \ r";
AnsiString s2="statistical results \ n";
Hfile=FileOpen (" TEST. TXT ", 1);
FileSeek (hfile, 10, 2);
FileWrite (hfile, s.c _str (), s.L ength ());
FileWrite (hfile, s1. C_str (), s1. The Length ());
FileWrite (hfile, s2. C_str (), s2. The Length ());
FileClose (hfile);

CodePudding user response:

AnsiString s="1234 \ r \ n ";
Binary written to the file to a new line \ r \ n
Text written automatically converting \ n \ r \ n, read the opposite

CodePudding user response:

Newline character '\ n' and return character '\ r
'Start a new line, as the name implies, a newline is a carriage return is back to the beginning of a line, so we usually write file called for a carriage return should be exact enter a newline
'\ n' 10 newline (newline)
'\ r' 13 carriage return (return)

Can also be expressed as' \ x0a 'and' \ x0d. (hexadecimal)
Under Windows, the carriage returns symbol is "\ r \ n".

CodePudding user response:


Table1 - & gt; The Last ().
If (Table1 - & gt; Eof)
Table1 - & gt; The Prior ();

You can see the data set pointer:
BOF
Record1
.
RecordN
EOF
  • Related