Using the code I keep getting the error "Cannot get geometry object from data you send to the GEOMETRY field" However, if i copy and paste the string into an MySQL editor the query runs fine. Any thoughts?
str开发者_开发百科ing geoPOINTSTRING = splitZippy[4] + " " + splitZippy[5];
string atGvar = "GeomFromText('Point(" + geoPOINTSTRING + ")');";
string mySQLfinishedProcessing = " insert into zipcodes " +
"set zipcode = '" + zipcodeString + "'" +
",State = '" + StateString + "'" +
",City = '" + CityString + "'" +
",GEOPoint = @g"+
",StateCode = '" + StateCodeString2 + "'";
MySqlConnection configCON = new MySqlConnection(SQLStringClass.zipCONString);
MySqlCommand CounterLogs = new MySqlCommand(mySQLfinishedProcessing, configCON);
CounterLogs.Parameters.AddWithValue("@g",(string)atGvar);
configCON.Open();
CounterLogs.ExecuteNonQuery();
configCON.Close();
You are completely misusing parameters.
A parameter is a raw value.
You're setting GEOPoint to the literal string GeomFromText('Point(something)');
You need to put the actual values in parameters—zipcodeString, StateString, CityString, geoPOINTSTRING, and StateCodeString2.
You would then write GEOPoint = GeomFromText(@pointString), where pointString is a parameter holding "Point(" + geoPOINTSTRING + ")" (The string you want to pass to GeomFromText)
加载中,请稍侯......
精彩评论