I have created a table in Sql server 2014 with the columns: Id (int), Geom (geometry), RouteId (int), Desc (varchar(MAX)) I have succeeded in making the table mappable through MapInfo I have checked .TAB file for the table, that it has IsReadOnly = false

Stil when i try to execute an insert query on the table I get the error messsage that the table is read only. Anyone knows how to fix this?

Also I cannot figure out how to write a correct insert query I have tried doing that on a copied version of the table code is as follows

Dim rId As Integer
Dim oPline as Object
rId = 20
Dim t As String
t = "test"
Create pline into variable oPline 2 (1,2)(1,3)

Insert into TestGeom1 (Geom, RouteId, Desc) VALUES (oPline, rId, t)

Writing like above I get the error messsage field Geom does not exist in table TestGeom1 If i replace Geom with obj or just remove it completely i get the error Expression does not evaluate to a column or a table name. So please who can tell me what is the correct syntax for this?

1 Answer 1

  1. Make sure that you have specified a unique primary key in the table in SQL Server. Also you could take advantage of the IDENTITY type so that you don't have to manage the ID's yourself.

  2. Make sure your text columns are defined as varchar and that they aren't wider than 254. Otherwise you might have an issue editing the data

  3. Once the table is opened in MapInfo Professional your spatial column is always called OBJ. So use this insert statement:

    Insert into TestGeom1 (OBJ, RouteId, Desc) VALUES (oPline, rId, t)

If you have a statement that works in the MapBasic window but doesn't work in the MapBasic application, you should have a look at your variable and function names. Maybe you have a variable using the same name as a table or column.

Also try to create the table in the database from MapInfo Professional using File > New, when specifying the location of the table, pick an open connection to your database. In this way you can create a new table directly in your database

If you use the Per Row Style option, the width of the column might prevnet you from editing the object. If the column is wider than 254, MapInfo Pro can't edit the column and so the spatial object also gets read-only

  • I am using identity in sql server problem there however is that the table is readonly when opened in MapInfo I dont know how to gain write access. May 13, 2014 at 9:00
  • Just to get on with it I have tried using Save copy as in MapInfo. And continue working on the copied table it is possible to write to that one I have tried drawing directly in the map window that works fine. Writing the exact query you suggested gives the error Expression does not evaluate to a column or a table name I have tried with only Id, RouteId fields that executes in the MapBasic window but executing from my mapbasic program I get the error message above again May 13, 2014 at 9:14
  • My unique primary key is the Id (int) field and i am using the IDENTITY type on that one. May 13, 2014 at 9:18
  • Oh, you have set the Desc column to the maximum width. MapInfo Professional can only write to it if it is 254 characters or less. Change it and reopen the table from the database May 13, 2014 at 9:45
  • Ok I will try that I only added the column because MapInfo asks for a character typed column when it makes the table mappable but it does not tell anything about what length is needed May 13, 2014 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.