开发者

Store an image in a SQL Server CE database C# Compact framework code

Hello I want to Insert Image to Database SQL CE using C# Compact framework..

my code

FileInfo Filfo=New FileInfo(OpenFileDialog1.FileName.ToSting());
Long LngLength=5;
FileStream fstrm=new FileStream(OpenFileDialog1.FileName.ToSting());
BinaryReader br=new BinaryReader(Fstrm);
byte[] data=br.ReadBytes(int)lngLenght);

string Query="insert into category(cm_id,cm_image) values(@id,@img)";
sqlcecommand cmd=new sqlcecommand(Query,cls.Connect());
cmd.parameters.add(new sqlcparameter("@id",(object)textbox1.text);
cmd.parameters.add(new sqlcparameter("@id",(object)data);
cmd.executenonquery();

but it showing error.... openfiledialog1 ,file not found....

my load image code

开发者_运维技巧
openfiledialog open=new opendailog();
open.filter="Image Files(*.jpg*bmp;|*.jpg;*bmp;

if(open.showdilog()==dialogresult.Ok)
{
    pitcherbox1.image=new bitmap(open.file);
}


FileInfo Filfo=New FileInfo(OpenFileDialog1.FileName.ToSting());
Long LngLength=5;
FileStream fstrm=new FileStream(OpenFileDialog1.FileName.ToSting());
BinaryReader br=new BinaryReader(Fstrm);
byte[] data=br.ReadBytes(int)lngLenght);    
string Query="insert into category(cm_id,cm_image) values(@id,@img)";
sqlcecommand cmd=new sqlcecommand(Query,cls.Connect());
cmd.parameters.add(new sqlcparameter("@id",(object)textbox1.text);
cmd.parameters.add(new sqlcparameter("@img",(object)data);
cmd.executenonquery();


From your error message it looks like the filter is invalid.

Try just *.jpg;*.bmp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜