mapbasic og spatial databases
TRANSCRIPT
-
7/27/2019 MapBasic Og Spatial Databases
1/19
Every connection is a new opportunity
MapBasic & spatiale databaser
Peter Horsbll Mller
Systems Engineer
Marts 2012 Every connection is a new opportunity
-
7/27/2019 MapBasic Og Spatial Databases
2/19
Every connection is a new opportunity
DBMS Sample[CONNECTIONS]
NUM_CONNECTIONS=4
[CONNECTION_1]
DESCRIPTION=DSN using FileDSN
CONNECTIONTYPE=FILEDSN
FILEDSN=SQL2008.DSN
TRUSTED_CONNECTION=1
[CONNECTION_2]
DESCRIPTION=DSN using DSN
CONNECTIONTYPE=DSN
DSN=OKGIS
TRUSTED_CONNECTION=0
USERNAME=AdminUserPASSWORD=Admin
[CONNECTION_3]
DESCRIPTION=Connection StringCONNECTIONTYPE=CONNECTIONSTRING
CONNECTIONSTRING=DSN=OKGIS;Trusted_Connection=Yes
[CONNECTION_4]
DESCRIPTION=Connection String 2
CONNECTIONTYPE=CONNECTIONSTRING
CONNECTIONSTRING=DRIVER=SQL Server Native Client
10.0;SERVER=localhost\sqlexpress;DATABASE=OKGIS2008
TRUSTED_CONNECTION=0
USERNAME=MI_MGR
PASSWORD=MI_MGR
-
7/27/2019 MapBasic Og Spatial Databases
3/19
Every connection is a new opportunity
DBMS Sample
-
7/27/2019 MapBasic Og Spatial Databases
4/19
Every connection is a new opportunity
Forudstning
Vi har en spatial database, her SQL Server 2008
Databasen indeholder MapInfo.MapInfo_MapCatalogtabellen
Der er spatiale tabeller i databasen, som ogs er registreret
i MapCatalog
-
7/27/2019 MapBasic Og Spatial Databases
5/19
Every connection is a new opportunity
bne en tilslutning
Server_Connect( toolkit, connect_string)
toolkit is a string value identifying the remote interface, for
example, "ODBC", "ORAINET". Valid values for toolkit can be obtained
from the Server_DriverInfo( ) function.
connect_stringis a string value with additional informationnecessary to obtain a connection to the database.
Dim nConnection As Integer
nConnection = Server_Connect(ODBC, DSN=GIS2008)
connect_string kan vre en lang rkketingsom angiver hvilken database ogbruger man nsker at tilslutte til og som. Vrdiernekan angives via endatakilde eller direkte i connect_string
http://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-26.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-26.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-26.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-26.html -
7/27/2019 MapBasic Og Spatial Databases
6/19
Every connection is a new opportunity
bne en tilslutning
MS Access database
Fil datakilde
-
7/27/2019 MapBasic Og Spatial Databases
7/19
Every connection is a new opportunity
bne en tilslutning
System datakilde
Tilslutningsstreng
-
7/27/2019 MapBasic Og Spatial Databases
8/19
Every connection is a new opportunity
Lukke en tilslutning
ServerConnectionNumberDisconnect
ConnectionNumberis an integer value that identifies the specific
connection.
Server1Disconnect
Server nConnectionDisconnect
-
7/27/2019 MapBasic Og Spatial Databases
9/19
Every connection is a new opportunity
Egenskaber p en tilslutningServer_ConnectInfo( ConnectionNo, Attr)
ConnectionNumberis the integer returned by the Server_Connect( ) function that
identifies the database connection.
Attris a code indicating which information to return.
http://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.html -
7/27/2019 MapBasic Og Spatial Databases
10/19
Every connection is a new opportunity
Sende kommandoer til databasen
Server_Execute( ConnectionNumber, server_string)
ConnectionNumberis an integer value that identifies the specific connection.
server_stringis any valid SQL statement supported by the connected server.
Refer to the SQL language guide of your server database for information on
valid SQL statements.
....
-
7/27/2019 MapBasic Og Spatial Databases
11/19
Every connection is a new opportunity
Analysere tabeller/tabelstruktur
Server_NumCols( StatementNumber)
StatementNumberis an integer value that identifies information about an SQL
statement.
-
7/27/2019 MapBasic Og Spatial Databases
12/19
Every connection is a new opportunity
Analysere tabeller/tabelstrukturServer_ColumnInfo( StatementNumber, ColumnNo, Attr)
StatementNumberis an integer value that identifies information
about an SQL statement.
ColumnNo is the number of the column in the table, starting at 1
with the leftmost column.
Attris a code indicating which aspect of the column to return.
-
7/27/2019 MapBasic Og Spatial Databases
13/19
Every connection is a new opportunity
Analysere tabeller/tabelstruktur
-
7/27/2019 MapBasic Og Spatial Databases
14/19
Every connection is a new opportunity
bne sammenkdet tabel fra databasenServer Link Table
SQLQuery
Using ConnectionString
Into TableName
Toolkit Toolkitname
[ FileFileSpec ]
[ ReadOnly ]
[Autokey { Off | On }]
ConnectionNumberis an integer value that identifies an existing connection.
SQLQueryis a SQL query statement (in native SQL dialect plus object keywords)
that generates a result set. The MapInfo linked table is linked to this result
set.
ConnectionStringis a string used to connect to a database server. See
Server_Connect( ) function.
TableName is the alias of the MapInfo table to create.
FileSpec is an optional tab filename. If the parameter is not present, the tab
filename is created based on the alias and current directory. If a FileSpec is
given and a tab file with this name already exists, an error occurs.
ReadOnly indicates that the table should not be edited.
Toolkitname is a string indicating the type of connection, ODBC or ORAINET.
ServerConnectionNumberLink Table
SQLQuery
Toolkit toolkitnameInto TableName
[ File FileSpec ]
[ ReadOnly ]
[Autokey { Off | On }]
http://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-19.html -
7/27/2019 MapBasic Og Spatial Databases
15/19
Every connection is a new opportunity
bne sammenkdet tabel fra databasen
-
7/27/2019 MapBasic Og Spatial Databases
16/19
Every connection is a new opportunity
bne direkte tabel fra databasenRegister Table source_file
Type ODBCConnection { Handleconnection_number| connection_string}
Toolkittoolkit_name
Cache { ON | OFF }
[Autokey { ON | OFF }]
TableSQLQuery
[Versioned{ ON | OFF }]
[WorkspaceWorkspace_name ]
[ ParentWorkspaceParentWorkspace_name ]
source_file is a string that represents the name of an existing database, spreadsheet, text
file, raster, or grid image. If you are registering an Access table, this argument must
identify a valid Access database.
connection_numberis an integer value that identifies an existing connection to an ODBC
database.
connection_stringis a string used to connect to a database server.
toolkit_name is "ODBC" or "ORAINET."
SQLQuery is the SQL query used to define the MapInfo table.Versioned indicates if the table to be opened is a version-enabled (ON) table or not (OFF).
Workspace_name is the name of the current workspace in which the table will be operated.
The name is case sensitive.
ParentWorkspace_name is the name of parent workspace of the current workspace.
Efterflgende skal den registrerede tabel bnes via Open Table
http://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-20.htmlhttp://localhost/var/www/apps/conversion/tmp/scratch_5/MapBasic-08-20.html -
7/27/2019 MapBasic Og Spatial Databases
17/19
Every connection is a new opportunity
bne direkte tabel fra databasen
-
7/27/2019 MapBasic Og Spatial Databases
18/19
Every connection is a new opportunity
Sprgsml?
Peter Horsbll Mller
mailto:[email protected]:[email protected] -
7/27/2019 MapBasic Og Spatial Databases
19/19
Every connection is a new opportunity
Every connection is a new opportunity