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
精彩评论