Delphi - Either BOF or EOF is True, or the current record has been deleted - sql-server-2005

This error showed when I tried to select on an empty table in MS SQL Server 2005: "either BOF or EOF is True, or the current record has been deleted". I have used TADOConnection and TADODataSet in Delphi 5 to connect and retrieve data from the database.
Conn := TADOConnection.Create(nil);
DataSet := TADODataSet.Create(nil);
Conn.ConnectionString := 'Provider=SQLOLEDB.1;Password=sa;' +
'Persist Security Info=True;' +
'User ID=user;Initial Catalog=mydb;' +
'Data Source=MYPC\SQLEXPRESS;' +
'Use Procedure for Prepare=1;' +
'Auto Translate=True;Packet Size=4096;' +
'Workstation ID=MYPC;' +
'Use Encryption for Data=False;' +
'Tag with column collation when possible=False';
Conn.LoginPrompt := False;
Conn.Open;
DataSet.Connection := Conn;
DataSet.CommandText := 'SELECT * FROM MYTABLE';
DataSet.Open;
DataSet.Free;
Conn.Free;
Is there a way to check if a database table is empty without incurring such error?

This error originally occured with an update to MDAC_TYP (to 2.6 from memory). According to an old Borland advisory
"This is a bug in the SQL Server provider. Set
CursorLocation = clUseClient to eliminate the error."
There was a ADOExpress patch available from Borland, but the link doesn't work. Embarcadero now host it here: ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/d5adoupdate2.exe(Thanks for the official link Jeroen!)
I would recommend downloading and installing all patches listed on the Embarcadero site, assuming you can find them.

Download the ADO update for Delphi 5 here: ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/d5adoupdate2.exe
Make sure you also have the regular update installed:
English Enterprise
English Professional
English Standard
There are more updates (Corba, original ADO install) and languages (French, German), but these should get you going.
There also used to be a http://info.borland.com/devsupport/delphi/download_files/zlibupdate.zip, but it is not on the ftpd servers.
--jeroen

It was long time agom but I recall that this problem in Delphi 5 resolves by Delphi update. Early version has serious problems with ADO components
P.S. Also I see that your code uses not typical runtime creation of components and does not use some container like data module or form (not good usually) for visual work with components. Also sometimes useful run simple queries via adoConnection.execute. If you do not use visual components, handling of ADO's Recordset object is much the same as Delphi's AdoDataset.

Since I spent a whole day on this, here is a wrap up of what I did in the end.
Delphi 5 Pro Installation with ADO Express
Uninstall Delphi 5, also deleted installation directory
Install Delphi 5 Pro (I only have a German Delphi Pro edition available)
Install Delphi 5 Pro Update (I used the German update)
Install Delphi 5 ADO Express
Install Delphi 5 ADO Express Update Pack 1
Install Delphi 5 ADO Express Update Pack 2
And the download links (many thanks again Jeroen Wiert Pluimers):
Delphi 5 Pro updates:
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/delphi5/D5ProUpdate.exe
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/delphi5/german/d5proupdate.exe
ADOExpress Update Packs 1 and 2:
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/D5ADOUpgrade.exe
ftp://ftpd.embarcadero.com/pub/delphi/devsupport/updates/adoexpress/d5adoupdate2.exe
And for future reference some screenshots to build the download links (case sensitive):

Related

Microsoft ACE DatabaseEngine 2010 driver (12.0) Problem, after Windows 10 1909 Cumulative Updates (and later)

since cumulative Windows 10 1909 Updates are installed, I get following exception when accessing MS Access accdb.
: An external component raised an exception.
After reinstalling Microsoft ACE DatabaseEngine 2010 (OLEDB.12.0 ..), all works fine again.
What can I do about it?
Dim sel As String = "Select Notiz from T_TerminNotiz where ztrText=#ztrText and serNr=#serNr"
Using myConnection As New OleDbConnection(myConnStringX1)
myConnection.Open()
Using mySqlCmd As New OleDbCommand(sel, myConnection)
mySqlCmd.CommandType = CommandType.Text
mySqlCmd.CommandTimeout = myCmdTimeOut
mySqlCmd.CommandText = sel
mySqlCmd.Parameters.Clear()
mySqlCmd.Parameters.Add(New OleDbParameter("#ztrText", OleDbType.VarChar)).Value = strKlient
mySqlCmd.Parameters.Add(New OleDbParameter("#serNr", OleDbType.Integer)).Value = serNr
oRet = mySqlCmd.ExecuteScalar()
End Using
End Using
Microsoft announces (Known issues with Office and Windows 10) that included Office 2010, but did not specify any technical details for developers.
However, you did the best thing, considering that you will (anyway) provide DatabaseEngine 2010 Redist for the client.
Sometimes, the problem is
due to a mismatch between the build configuration platform of your
project and the Microsoft Access Database Engine which is installed on
your machine.
As stated in this answer [by/ Katia]. Hope this helps. Best of luck.
after some tests, I found following solution to my problem.
Installing Microsoft DatabaseEngine 2016.
I activated all OLE DB Services by adding it into configuration file xxx.config.
...
connectionString="Provider=Microsoft.ACE.OLEDB.16.0;Data Source=Table.accdb;Persist Security Info=True;OLE DB Services=-1;

How to edit XML column in SQL Developer?

I would like to edit XML column which is displaying as (XMLTYPE) by SQL Developer editor (I go there by clicking on the field twice, edit, then save).
After that the displayed value changes to sqldev.xml:/home/myuser/.sqldeveloper/tmp/XMLType8226206531089284015.xml
Build after save retrieving next build context...
Build after save building project 1 of 1 queued projects
Compiling...
Ignoring /home/username/.sqldeveloper/tmp/XMLType5691884284875805681.xml; not on source path
[11:45:33 AM] Compilation complete: 0 errors, 1 warnings.
Build after save finished
and when I try to commit:
UPDATE "USERNAME"."TABLENAME" SET WHERE ROWID = 'AABWNKAAEAAABSbAAB' AND ORA_ROWSCN = '6951979'
One error saving changes to table "USERNAME"."TABLENAME":
Row 1: Illegal format in column NEXTCOLUMN.
I tried to look for this error and found people who also had it, but without the solution.
If you have an advice how to report it to Oracle, it will be also helpful.
Hope this will be of help to you:
UPDATE table_name
SET table_column=
UPDATEXML(table_column,
'/sampleTag1/sampleTag2/text()','value2')
WHERE some_column = some value --<< this part is where you put your condition
Here is where you can find more about it:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions205.htm
-------------------------
If your problem is with editing through SQL developer manually via integrated editor then it is, as far as my testing and researching can tell, because of the SQL Developer version.
You have noted in your comment that you use version 4.1.x and I have found few places where people confirm that they had the same problem with this version.
I also have 4.1.x version and I have also successfully repeated your error where the developer is referring to my .xml file in my ...\sqldeveloper\tmp folder not being on it's source path :
Compiling... Ignoring C:\Users\trle\AppData\Roaming\SQL
Developer\tmp\XMLType6413036461637067751.xml; not on source path
[4:33:29 PM] Compilation complete: 0 errors, 1 warnings.
I have then downloaded version 19.2.x where there is no such problem and all works just fine.
So my answer to your problem is to download some newer version of SQL developer. In my case 19.2. works.
-------------------------
UPDATE Just tested on version 4.2.x - also works

SQL looking for a part number ending in '~0000'

I am trying to find records ending in ~0000 such as ABC~0000
but everything I try doesn't seem to work. Some examples:
and left (mfr_part_number, 4) = 'ABC~' -- finds nothing
and left (mfr_part_number, 3) = 'ABC' -- finds stuff
AND RIGHT(MFR_PART_NUMBER, 4) = '0000' -- finds nothing
AND RIGHT(MFR_PART_NUMBER, 5) = '~0000' -- finds nothing
and DbFunctions.Like(MFR_PART_NUMBER,'%0000') -- suggested elsewhere, but not recognized in MSSMS.
I am using:
SQL Server Management Studio 15.0.18206.0
Microsoft Analysis Services Client Tools 15.0.1567.0
Microsoft Data Access Components (MDAC) 10.0.18362.1
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.18363
Thanks!
Are you using all of those AND statements in your WHERE clause? If so, that would cause nothing to return if there's no data that matches all criteria.
Try
SELECT column1, column2...
FROM yourdb
WHERE MFR_PART_NUMBER LIKE '%0000'

SQL Error -4903 when trying to connect to DB2 database

I am getting an SQL error code of -4903 when trying to connect to a DB2 database using SQC code (this is an ANSI C application so I need to use SQC for SQL queries). When I look at IBM's website to see what a -4903 means, all it says is "The length of parameter n of function name is not valid". However I have no idea which parameter or function it is referring to. I have tried looking at the SQLCA objects members, but I am unable to see them in Visual Studio 2015.
This is an ANSI C application debugging in Visual Studio 2015. I am able to connect to the same database using a DB2 command prompt (i.e, by running "db2 connect to dbname user username using password". However when I try to do this in code I get the -4903 error. I have also tried this on two different OS's, Windows 7 and Windows 10. I have colleagues who have had no trouble doing this on a Windows 7 machine.
while ((retry++ < 3)
|| (sqlca.sqlcode == -30080)
|| (sqlca.sqlcode == -900 ) )
{
EXEC SQL CONNECT TO :DBName USER :userid USING :pword;
if ((SQLCODE == 0 ) || (SQLCODE == (-1026)))
{
return(1);
}
else
{
dbLogAudit(KLCB, PLCB, KLLOGSEV(T),
"Retry DBInit/sqlca.sqlcode : %i", sqlca.sqlcode);
}
}
I expect the SQLCODE to be 0, which indicates a successful connection, and for the function to return 1 to it's caller. But instead the sqlca.sqlcode variable is -4903 (which I described above).
EDIT: I found the parameters being passed into the error message. The full error text is "The length of parameter runtime_pid of function sqlastrt_trusted is not valid".
I solved my own issue. Thanks to Mao for the help on debugging this one.
My development environment for DB2 was running version 8.1.0, which uses 162 bytes for the struct called "sqla_program_id". However, the runtime environment, which uses 292 bytes for that same struct, was version 10.5. Once I upgraded my development DB2 instance to v10.5 it worked like a charm.

ORA 06401 invalid driver designator

I have a old VB .NET application.
It works with oracle 11 personal edition.
i move this application in other server with oracle 12 C enterprise edition and the application dont connect herself to DB with the following error code."ORA 06401 invalid driver designator ".
This is the connection string "Provider=OraOLEDB.Oracle;Password=xx User Id=yy DataSource=//localhost:1521//zzz extended Properties=;"
Probably is a very trivial mistake but I 've already lost a day
Thanks to all
Gian