我想在点击database
时将Windows Form
行插入geography
点(使用SQL Server
),然后在用户点击的位置绘制图片。我从x
获得y
和MousePosition.X
坐标,但是当我将这些值插入数据库时:
string connetionString = null;
connetionString = "Data Source=DEVEL-MACHINE\\DEVELOPINSTANCE;Initial Catalog=spdb;Integrated Security=True" ;
cnn = new SqlConnection(connetionString);
try
{
cnn.Open();
String query = "INSERT INTO vertex VALUES( geography::Parse('POINT(" + MousePosition.X.ToString() + " " + MousePosition.Y.ToString() + ")'),'" + nameBox.Text + "')";
SqlCommand command = new SqlCommand(query, cnn);
command.ExecuteNonQuery();
cnn.Close();
}
catch (Exception ex)
{
statuslbl.Text = "Status połączenia: BRAK";
statuslbl.BackColor = Color.Red;
statuslbl.Visible = true;
}
我收到错误
类型' System.Data.SqlClient.SqlException'未处理的异常 发生在System.Data.dll
中其他信息:期间发生了.NET Framework错误 执行用户定义的例程或聚合" geography":
我的查询外观"INSERT INTO vertex VALUES( geography::Parse('POINT(600 379)'),'test')"
有没有办法将表格坐标视为geopoint
以恢复操作?我的意思是以一种方式存储像geopoint
那样的坐标,然后在表格select
上得到600 379
点的图像后<?p}?