Your statement is a little too vague. What is it that ‘does not work’?
Does AddLayerFromDatabase seem to work (i.e. does it return an id >= 0)?
a. If the layer is not added successfully, you should verify your connection string and existence of a table named GEO_LAYER.
The second line Map1.OgrLayer[id] is unnecessary, and can be removed.
If the layer is successfully added, is there an error that is occurring after that? or do you just not see the layer?
Please provide more information and we’ll try to help you figure it out.
Just to verify the connection, try something like the following (based on some sample code). One thing I noticed is that your connection string doesn’t have a GDAL prefix. For example, when connecting to SQL Server, you prefix the connection string with “MSSQL:” I’m not sure, but for ODBC, you may need a prefix like “ODBC:”. But try the following and see if you get back an error. Then we can take it from there.
private static string CONNECTION_STRING = "Provider=OraOLEDB.Oracle.1;Password=xxxxx,Persist Security Info=True;User ID=xxxx;Data Source=bd";
var ds = new OgrDatasource;
if (!ds.Open(CONNECTION_STRING))
{
Debug.Print("Failed to establish connection: " + ds.GdalLastErrorMsg);
}
Yes, it should be possible. GDAL has a driver for Oracle Spatial (https://gdal.org/drivers/vector/oci.html). And I think you should also be able to use the ODBC driver (as specified here) (and it looks like you need the ODBC prefix, look at the samples provided by GDAL).
Did you try connecting using the sample code I provided? If you got an error, what was the error?
Good Morning,
I develop in delphi.
but it does not even show the error message.
Gives the message “acess violation”
Follow the routine
var
dt: OgrDatasource;
begin
// Oracle
conn: = ‘Provider = OraOLEDB.Oracle.1; Password = xxxxx, Persist Security Info = True; User ID = xxxx; Data Source = bd’;
query: = ‘select * from sgib.GEO_LAYER’;
try
dt.Open (conn);
except
on E: Exception of
begin
ShowMessage (‘Err:’ + E.Message);
end;
end;
end;
Hi,
I continue to study how to connect to an oracle database using delphi 10.3 with Mapwingis 5.1.1.
follow my connection string and sql
conn: = ‘OCI: username / password @ server: port / DB’;
query: = ‘select * from table’;
follow my command
id: = Map1.AddLayerFromDatabase (conn, Query, True);
-> if id returns -1 then it went wrong.
Hello,
I still can’t access oracle database.
But I did tests with sql server:
In version 4.9.6.1 it works perfectly and in version 5.1.1 does not load the polygon.