sqlserver provider and varchar index

Topics: Data Access, WinForms Controls
Sep 18, 2014 at 5:14 PM
Hello all,

I have a sqlserver2008r2 db called test with a table called prop:

CREATE TABLE [dbo].[prop]([G_PROP_ID] nvarchar( 18 ) NOT NULL,[G_POINT] [geometry] NULL CONSTRAINT [PK_prop] PRIMARY KEY CLUSTERED ([G_PROP_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]

and one record:

INSERT INTO (g_prop_id,g_point) VALUES ('05025000000004033', 'POINT (467428.936 4214661.587)')

Now I create a new datasource and the corresponding layer (Sharpmap 1.1.0)

dim LayPoint as VectorLayer = new VectorLayer('test')
LayPoint.DataSource = New Data.Providers.SqlServer2008("DataSource=localhost\sqlexpress;Initial Catalog=test;Integrated Security=True","prop","G_POINT","G_PROP_ID")

The layer is created ok and displayed on a mapbox. However when I try to get a FeatureDataRow

Dim f As FeatureDataRow = LayPoint.DataSource.GetFeature(1)

I get a conversion error as follows

"The conversion of the nvarchar value '05025000000004033' overflowed an int column."

I guess that this has something to do with my primary key which is of type nvarchar(18) containing some integer values, however this is really something I have to deal with

Any ideas?
Coordinator
Sep 19, 2014 at 7:07 AM
I'm sorry, you will have to add a (computed) column that has unique values that can fit into an System.UInt32.