Board index » delphi » Help me please: Major problems with ADO

Help me please: Major problems with ADO

Chris

Quote
>2) create a table called testTable, with 2 fields
>   Field 1 - name = ID, Autonumber
>   Field 2 - Name : Text - default 50 bytes

Try changing the name of the 2nd column to something else, like FullName.  I
am not sure where, but somewhere in the ADO path between your program and
the DB, NAME appears to be a reserve word.  This was a problem that drove me
crazy several months ago.  I noticed that using LOCATION also gave me
problems.

Joe

 

Re:Help me please: Major problems with ADO


Hi,
  I am using Access 97 Jet 3.51 database for this test, could you please
try
this code and see if it fails for you, and if so you might know why, I
really am at a loss here.

To get it to work you need to do this:

1) Create an Access 97 Database called c:\temp\adotest.mdb
2) create a table called testTable, with 2 fields
   Field 1 - name = ID, Autonumber
   Field 2 - Name : Text - default 50 bytes

   Set Field 1 to Primary Key

Create a delphi application, drop on a TAdoTable, and a TAdoQuery and a
TBitBtn on the form, and then put this code in the Button OnClick Event

procedure TForm1.Button1Click(Sender: TObject);
Var
 NewID, DatabaseLocation,
 CallCentralConnectionStr : String;
begin
  DatabaseLocation := 'c:\temp\adotest.mdb';
  CallCentralConnectionStr := 'Provider=Microsoft.Jet.OLEDB.3.51;Persist
Security Info=False;User ID=Admin;';
  CallCentralConnectionStr := CallCentralConnectionStr + 'Data
Source='+DatabaseLocation+';';
  CallCentralConnectionStr := CallCentralConnectionStr + 'Mode=Share Deny
None;Extended Properties=";COUNTRY=0;CP=1252;LANGID=0x0409";';
  CallCentralConnectionStr := CallCentralConnectionStr + 'Locale
Identifier=1033;Jet OLEDB:System database="";Jet OLEDB:Registry
Path="";';
  CallCentralConnectionStr := CallCentralConnectionStr + 'Jet
OLEDB:Database
Password="";Jet OLEDB:Global Partial Bulk Ops=2';

  AdoTable1.CursorLocation := cluseServer;
  AdoTable1.ConnectionString := CallCentralConnectionStr;

  AdoQuery1.CursorLocation := cluseServer;
  AdoQuery1.ConnectionString := CallCentralConnectionStr;

  ADOTable1.tableName := 'TestTable';
  ADOTable1.Open;
  ADOTable1.Append;
    ADOTable1.FieldByName('Name').AsString := 'Testing ADO';
  ADOTable1.Post;

// sleep(1000);

  NewID := ADOTable1.FieldByName('ID').AsString;
  ADOQuery1.SQL.Clear;
  ADOQuery1.SQL.Add('Select * from TestTable where [id] = '+NewID);

  // Sleep(1000);

  ADOQuery1.Open;
  if (ADOQuery1.RecordCount = 0) then
    ShowMessage('Record not found!')
  else
    begin
      ADOQuery1.Edit;
        ADOQuery1.FieldByName('Name').AsString := 'Testing ADO Again';
      ADOQuery1.Post;
    end;
  AdoQuery1.Close;

  ADOTable1.Edit;
    ADOTable1.FieldByName('Name').AsString := 'Testing ADO Again, and
Again';
  ADOTable1.Post;
  ADOTable1.Close;
end;

If you "step through the code", the 3rd post (the last one) will cause
this
error "Error Occurred", not a very usefull message.

If you run the code normally, you will get the message "Record Not
Found",
because the query returns no records for some reason.

If you put a Delay of 1000 after the first post, and run the program you
then get the message "Errors Occured", but if you remove the delay after
the
first post, and put a Delay of 1000 before the AdroQuery1.Open it returns

a
message "Not a valid bookmark"

What am I doing wrong? or what are these ADO Components doing?

PLEASE try this out and let me know if it fails on your machines...

Chris

Re:Help me please: Major problems with ADO


try to install jet 4

Alex.

Re:Help me please: Major problems with ADO


Quote
Chris Crowe <Ch...@Adrock.com> wrote in message

news:MPG.12e677f69cbce681989682@forums.inprise.com...

Quote
>   I am using Access 97 Jet 3.51 database for this test, could you please

The AutoNumber field with the Jet 3.51 provider is going to have problems in
this scenario.  If you upgrade to an Access 2000 database and use the Jet 4
provider that should take care of the problem.

Mark

Other Threads