我一直有这样的错误“你的SQL语法有错误;请查看与你的MySQL服务器版本相对应的手册,以便在'='附近使用正确的语法”。 columnfield是从另一个函数传递的动态var。
我的代码是:
c.execute("UPDATE cases SET" +columnfield+"=%s WHERE id=%s",(thwart(gethash),thwart(caseid)))
知道我哪里做错了吗?
答案 0 :(得分:1)
我认为你需要一个字public partial class MainWindow : Window
{
public double MainWindowOpacity
{
get { return (double)GetValue(MainWindowOpacityProperty); }
set { SetValue(MainWindowOpacityProperty, value); }
}
// Using a DependencyProperty as the backing store for MainWindowOpacity. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MainWindowOpacityProperty =
DependencyProperty.Register("MainWindowOpacity", typeof(double), typeof(MainWindow), new PropertyMetadata(1.0));
public MainWindow()
{
InitializeComponent();
DataContext = this;
Loaded += MainWindow_Loaded;
}
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//if (MainWindowOpacity < 1) MainWindowOpacity = 1.0;
//else MainWindowOpacity = 0.5;
MainWindowOpacity = 0.5;
// show dialog
// boilerplate code from http://stackoverflow.com/questions/6417558/modal-dialog-not-showing-on-top-of-other-windows
Window window = new Window()
{
Title = "WPF Modal Dialog",
ShowInTaskbar = false, // don't show the dialog on the taskbar
Topmost = true, // ensure we're Always On Top
ResizeMode = ResizeMode.NoResize, // remove excess caption bar buttons
Owner = Application.Current.MainWindow,
Width = 300,
Height = 200
};
window.ShowDialog();
MainWindowOpacity = 1.0;
}
}
之后的空格。这就是全部。
现在你创建了一个奇怪的单词SET
更好地创建语句(在SETcolumname=
之前)并打印它以查看它的外观。然后你也可以直接在MySQL中使用它。数据库为您提供了更好的错误消息,您可以在数据库中对其进行测试,直到获得预期的结果。