C# 如何用C语言在mysql数据库中存储图像路径#

C# 如何用C语言在mysql数据库中存储图像路径#,c#,mysql,winforms,C#,Mysql,Winforms,我正在开发windows窗体,以便在数据库中保存图像路径,然后使用存储在数据库中的图像路径检索该图像。我的代码保存路径,但不包括斜杠“/”。因此,请帮助我如何正确保存图像路径。这是我的密码 private void button3_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) {

我正在开发windows窗体,以便在数据库中保存图像路径,然后使用存储在数据库中的图像路径检索该图像。我的代码保存路径,但不包括斜杠“/”。因此,请帮助我如何正确保存图像路径。这是我的密码

private void button3_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                imagePath = openFileDialog1.FileName.ToString();
                label23.Text = openFileDialog1.SafeFileName.ToString();
                Image thumbnail = Image.FromFile(openFileDialog1.FileName).GetThumbnailImage(214, 186, () => false, IntPtr.Zero);
                pictureBox1.Image = thumbnail;
                command.CommandText = "insert into student values ('imagePaht')";
                con.Open();
                command.Connection = con;
                command.ExecuteNonQuery();
                con.Close();

            }
        }

使用
@
以避免删除斜杠。另一个办法是加倍,但这不是一个好办法

command.CommandText = @"insert into student values ('imagePaht')";

我认为
imagePaht
是一个局部变量。它到底有什么价值?您需要在
CommandText
行末尾使用双引号(
)。imagePath是全局变量,很抱歉我忘记了问题中的引号,但我的查询运行,它保存了条目,但不保存斜杠(“/”)。斜杠被排除在数据库中,这就是它不读取图像的原因。