如何解决这个错误在c#windows窗体中保存关键字附近的错误语法 [英] how to solv this error incorrect syntax near save keyword in c# windows form

查看:82
本文介绍了如何解决这个错误在c#windows窗体中保存关键字附近的错误语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将图像从数据库中检索到我的图片框,因为我使用下面的代码代码。

I have to retrive the image from database to my picturebox for that i use this code below sis the code.

SqlConnection connect = new SqlConnection(@"Data Source=USER;Initial Catalog=SAVERETRIVEDEMO;Integrated Security=True");
            SqlCommand command = new SqlCommand
                                ("select Image from save&Retriveimagedemo where ID=1", connect);
            //for retrieving the image field in SQL SERVER EXPRESS
            //Database you should first bring
            //that image in DataList or DataTable
            //then add the content to the byte[] array.
            //That's ALL!
            SqlDataAdapter dp = new SqlDataAdapter(command);
            DataSet ds = new DataSet("MyImages");

            byte[] MyData = new byte[0];

            dp.Fill(ds, "MyImages");(HERE I GOT ERROR INCORRECT SYNTAX NEAR SAVE KEYWORD)
            DataRow myRow;
            myRow = ds.Tables["MyImages"].Rows[0];

            MyData = (byte[])myRow["fldPic"];

            MemoryStream stream = new MemoryStream(MyData);
            //With the code below, you are in fact converting the byte array of image
            //to the real image.
            pictureBox2.Image = Image.FromStream(stream);
        } 









Plzz帮助我如何retive从数据库到图片框的图像,也想要图像是retrive.plz的字节数组给出适当的代码.. plz it ugent。





Plzz help me how to retive the image from database to picturebox and also want the byte array in which the image is retrive.plz give appropriate code for that.. plz its ugent.

推荐答案

我'我把它格式化了一下,这样就可以正常阅读了。



你的错误在你的表名中...如果你的表名中有特殊字符(例如&)你应该使用方括号,如下所示:[save& Retrieveimagedemo]





如果这有帮助请花点时间接受解决方案。谢谢。
I've formatted it a bit so it can be read properly.

Your error is in the name of your table...if you have special characters in your table names (such as &) you should use it with square brackets like this: [save&Retrieveimagedemo]


If this helps please take time to accept the solution. Thank you.


这篇关于如何解决这个错误在c#windows窗体中保存关键字附近的错误语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆