gpt4 book ai didi

sql - MS-Access:SQL UPDATE 语法错误,但为什么呢?

转载 作者:行者123 更新时间:2023-12-03 08:00:43 26 4
gpt4 key购买 nike

我在此 SQL 中遇到语法错误,似乎无法弄清楚原因?

SQL UPDATE 在错误时返回这个:

UPDATE Tankstationer 
SET Long='12.5308724', Lat='55.6788735'
WHERE Id = 2;

这是我的代码:
foreach (var row in reader)
{
var id = reader.GetInt32(0);
var adress = reader.GetString(1);
var zip = reader.GetDouble(2);
var city = reader.GetString(3);
var adressToParse = adress + " " + zip + " " + city;

GMapGeocoder.Containers.Results result = Util.Geocode(adressToParse, key);
foreach (GMapGeocoder.Containers.USAddress USAdress in result.Addresses )
{
var google_long = convertNumberToDottedGoogleMapsValid(USAdress.Coordinates.Longitude);
var google_lat = convertNumberToDottedGoogleMapsValid(USAdress.Coordinates.Latitude);
Message.Text = "Lattitude: " + google_long + System.Environment.NewLine;
Message.Text = "Longitude: " + google_lat + System.Environment.NewLine;
string updatesql = "UPDATE Tankstationer SET Long='" +google_long+ "', Lat='" +google_lat+ "' WHERE Id = " +id+"";
OleDbCommand update = new OleDbCommand();
update.CommandText = updatesql;
update.Connection = conn;
reader = update.ExecuteReader();
Message.Text = "Done";
}
}

最佳答案

“长”是 Access 中的保留字。如果您无法更改架构以将该列称为其他名称,请将其放在括号中:

UPDATE Tankstationer
SET [Long]='12.5308724', Lat='55.6788735'
WHERE Id = 2;

关于sql - MS-Access:SQL UPDATE 语法错误,但为什么呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4678679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com