after your first post, try moving to the last record. Posting, even tho
there is only one record in the db, might need to know "WHERE" it
is.....might be worth a try.
Jeremy Coulter
Application Developer
Application Development Centre
Compaq Computer New Zealand Ltd.
Phone: 64 3 371 5724
Fax: 64 3 371 5724
Mobile: 64 0212533214
E-mail: [EMAIL PROTECTED]
Personal Email: [EMAIL PROTECTED]
-----Original Message-----
From: Chris Crowe [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 12, 2000 10:07 AM
To: Multiple recipients of list delphi
Subject: [DUG]: MAJOR ADO PROBLEMS - Please try this code and let me
know if you get the same results
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
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz