Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试使用c在access数据库中插入数据时出错#_C#_Mysql_Database_Insert_Memorystream - Fatal编程技术网

C# 尝试使用c在access数据库中插入数据时出错#

C# 尝试使用c在access数据库中插入数据时出错#,c#,mysql,database,insert,memorystream,C#,Mysql,Database,Insert,Memorystream,Visual Studio在尝试将数据保存到access数据库时出现以下错误: OLEDBEException(0x80040E14):INSERT INTO命令中的语法错误 单击“保存”按钮(“btnfoliespeichen”)后出现错误 在我的数据库表“Folien”中,“Hersteller”、“Serie”和“Farbe”是字符串,“EK Preis”是双精度的,“Bild”是OLE对象 这是我的密码: private void btnFolieSpeichern_Click(obje

Visual Studio在尝试将数据保存到access数据库时出现以下错误:

OLEDBEException(0x80040E14):INSERT INTO命令中的语法错误

单击“保存”按钮(“btnfoliespeichen”)后出现错误

在我的数据库表“Folien”中,“Hersteller”、“Serie”和“Farbe”是字符串,“EK Preis”是双精度的,“Bild”是OLE对象

这是我的密码:

private void btnFolieSpeichern_Click(object sender, EventArgs e)
{
    try
    {
        connection.Open();
        OleDbCommand command = new OleDbCommand();
        command.Connection = connection;
        command.CommandText = "INSERT INTO Folien (Hersteller,Serie,Farbe,EK-Preis,Bild) VALUES ('" + tbFolieHersteller.Text + "','" + tbFolieSerie.Text + "','" + tbFolieFarbe.Text + "','" + tbFolieEKPreis.Text + "',@folienbild)";

        //converting photo to binary data
        if (pbFolieBildHinzufügen.Image != null)
        {
            MemoryStream ms = new MemoryStream();
            pbFolieBildHinzufügen.Image.Save(ms, ImageFormat.Jpeg);
            byte[] photo_aray = new byte[ms.Length];
            ms.Position = 0;
            ms.Read(photo_aray, 0, photo_aray.Length);
            command.Parameters.AddWithValue("@folienbild", photo_aray);
        }

        command.ExecuteNonQuery();
        MessageBox.Show("Folie erfolgreich hinzugefügt!", "Erfolgreich!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        connection.Close();

        tbFolieHersteller.Text = "";
        tbFolieSerie.Text = "";
        tbFolieFarbe.Text = "";
        tbFolieEKPreis.Text = "";
        pbFolieBildHinzufügen.Image = null;
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error " + ex);
    }
}
加载图片的代码:

private void btnBildLaden_Click(object sender, EventArgs e)
{
    openFileDialog3.Filter = "jpeg|*.jpg|png|*.png|bmp|*.bmp|all files|*.*";
    DialogResult res = openFileDialog3.ShowDialog();
    if (res == DialogResult.OK)
    {
        pbFolieBildHinzufügen.Image = Image.FromFile(openFileDialog3.FileName);
    }
}
错误消息:

我试着用'55'、'55.0'和'55,0'填充tbFolieEKPreis


谢谢你的帮助

使用括号
[EK Preis]
在哪里@juergend
EK Preis
包含特殊字符。用括号括住那个列名来转义Itah明白了,谢谢,工作得很好!您的代码易受SQL注入攻击