Apr 6, 2008 at 9:49 AM
Edited Apr 6, 2008 at 9:53 AM
i download the latest version of sharp map and compile it
and i download the nts_demo from extesion section
i change add layer section for get map from postgis
but show error in postgis.cs
in function GetFeatureCount()
public int GetFeatureCount()
int count = 0;
using (Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(_ConnectionString))
string strSQL = "SELECT COUNT(*) FROM " + this.Table;
strSQL += " WHERE " + this.DefinitionQuery;
using (Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(strSQL, conn))
conn.Open(); ///////////////////////**********************************//////////////////////Specified cast is not valid.
count = (int)command.ExecuteScalar();
i hav'nt any idea
i 'm newbe
please help me
Apr 8, 2008 at 7:42 PM
Edited Apr 8, 2008 at 9:07 PM
Hey, this was an actual bug, thanks for reporting it.
ExecuteScalar internally creates an Int64, but returns it as Object. You can cast the Object back to Int64 and an Int64 to an int, but by doing the (int) cast directly onto the Object things go wrong.
It could be solved like this:
count = (int)((Int64)command.ExecuteScalar());
I did it like this:
count = Convert.ToInt32(command.ExecuteScalar());
Change Set 32763 should solve your problem.