georeference.org
Subscribe to this thread
Home - Scripting / All posts - Import Drawing from SQL via vbscript
gpsit
28 post(s)
#05-Jul-09 16:48

Hi,

Does anyone know how to import a drawing from SQL server 2008 as a drawing? I can't use UI scripting as I am running the script outside of manifold. What I have working at the moment is importing the data as a table then linking a drawing to the table. The import script I am using is as follows:

//vbscript

Set SQLImport=doc.NewImport("SQL Server")

SQLImport.ConnectionString = "XXXXXXXX"

TableName= "SQLTable"

SQLImport.import (TableName)

Looking at manifold's object model and browsing the forum it appears that importing a drawing from SQL using NewImport is not possible. Hopefully someone can prove me wrong!

tjhb

3,200 post(s)
#05-Jul-09 18:43

I don't know how to do it in detail, and I might be wrong, but I think you want

Document.NewDataSource()

which returns a DataSource object, then

DataSource.ConnectionType ["SQL Server"]

DataSource.ConnectionString

then one of

DataSource.ImportDrawing

DataSource.LinkDrawing

gpsit
28 post(s)
#05-Jul-09 19:37

Cheers this works perfectly!

Set SQLImport=doc.NewDataSource()

SQLImport.ConnectionString = "XXXXXXX"

SQLImport.ConnectionType ="SQL Server"

TableName= "dbo.TableName.Geometry" <= needs ".Geometry" added to the tablename

SQLImport.ImportDrawing (TableName)

0 msec Copyright (C) 2007-2008 Manifold.net. All rights reserved.