[gdal-dev] Ogr to access MSSQL DB

Benjamin benjamin.lux at maxsea.fr
Wed Jul 11 03:32:46 PDT 2012


Hi,

I try to connect my application to a DB with the framework Ogr (with C#
warper).
When I write folloing code, Ogr methods view the DB but can't read it.

[code]
            Ogr.RegisterAll();

            const string connectionString =
@"Server=SERVEUR_NAME;Database=DATABASE_NAME;trusted_connection=yes";

            DataSource pnn3 = Ogr.Open("MSSQL:" + connectionString, 0);
            if (pnn3 == null)
                       throw new IOException("Creation of output file
failed.");
            
            Console.WriteLine("pnn3.Name\t=" + pnn3.name);
            Console.WriteLine("pnn3.GetLayerCount()\t= " +
pnn3.GetLayerCount());
[/code]

It display :
[quote]
Server=SERVEUR_NAME;Database=DATABASE_NAME;trusted_connection=yes
0
[/quote]

I know my DB is view because if I switch SERVEUR_NAME and/or DATABASE_NAME
by an other name the exception is throwed
On the other hand driver don't see my layers (it displays 0, and my db has
near to 30 layers).

If someone have already connected to db MSSQL, can him suggests me an
example of code (in C or C++ it is also great, it may help me) ?

Notes:
I use gdal-1.9.0 (with MSSQL Driver)
link usefull :  http://www.gdal.org/ogr/drv_mssqlspatial.html MSSQLSpatial -
Microsoft SQL Server Spatial Database 

Best regards,
Benjamin.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/gdal-dev-Ogr-to-access-MSSQL-DB-tp4987592.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120711/d4a7c24f/attachment-0001.html>


More information about the gdal-dev mailing list