[gdal-dev] Ogr to access MSSQL DB

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Ogr to access MSSQL DB

Benjamin
This post was updated on .
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 : MSSQLSpatial - Microsoft SQL Server Spatial Database

Best regards,
Benjamin.
Reply | Threaded
Open this post in threaded view
|

Re: Ogr to access MSSQL DB

Tamas Szekeres
Benjamin,

What is the content of the geometry_columns metadata table in your database?

Best regards,

Tamas



2012/7/11 Benjamin <[hidden email]>
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 : MSSQLSpatial - Microsoft SQL Server Spatial Database Best regards, Benjamin.

View this message in context: [gdal-dev] Ogr to access MSSQL DB
Sent from the GDAL - Dev mailing list archive at Nabble.com.

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Ogr to access MSSQL DB

Benjamin
Is the geometry_columns table mandatory ?
Because I have not such table.

This table is not in the spatial standard, isn't it ?
Ogr need to acces it ?

If yes, I think I will have to create it.

Thx for the clue,
Benjamin.
Reply | Threaded
Open this post in threaded view
|

Re: Ogr to access MSSQL DB

Tamas Szekeres
It is required with the current ogr driver, however we could implement some support to eliminate. This table is anyway included in the simple features specification for databases standard.
If you create the layers by using ogr (ie. by using ogr2ogr command line tool) the metadata tables are also created if necessary.

Best regards,

Tamas



2012/7/11 Benjamin <[hidden email]>
Is the geometry_columns table mandatory ?
Because I have not such table.

This table is not in the spatial standard, isn't it ?
Ogr need to acces it ?

If yes, I think I will have to create it.

Thx for the clue,
Benjamin.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/gdal-dev-Ogr-to-access-MSSQL-DB-tp4987592p4987674.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev