0

你能确定我的错误在哪里吗?当我运行这个时,我得到一个错误ExecuteNonQuery

'@geoPoint' 附近的语法不正确

sqlConnection.Open();

string commandText = "INSERT INTO shapefileTest (state, nrng, twp, lgnt, type, ntwp, meridian, rdir, tdir, rng, stcty, county, shape) VALUES ('" + state + "', '" + nrng + "', '" + twp + "' , " + lgnt + ", '" + type + "', '" + ntwp + "', '" + meridian + "', '" + rdir + "', '" + tdir + "', '" + rng + "', '" + stcty + "', '" + county + "',  @geoPoint";

SqlCommand sqlComm = new SqlCommand(commandText, sqlConnection);
SqlParameter param = new SqlParameter();
param.ParameterName = "@geoPoint";
param.UdtTypeName = "Geography";
param.Value = sqlGeog;

sqlComm.Parameters.Add(param);

sqlComm.ExecuteNonQuery();
sqlConnection.Close();
4

1 回答 1

5

你错过了最后的括号),除非那是一个错字

string commandText = "INSERT INTO shapefileTest (
    state, nrng, twp, lgnt, type, ntwp, meridian, rdir, tdir, rng, stcty, county, shape)     
    VALUES ('" + state + "', '" + nrng + "', '" + twp + "' , " + lgnt + ", '" + type 
    + "', '" + ntwp + "', '" + meridian + "', '" + rdir + "', '" + tdir + "', '" 
    + rng + "', '" + stcty + "', '" + county + "',  @geoPoint)";
                                                             ^
                                                             ^
                                                             ^
于 2013-06-12T14:50:15.603 回答