将图像存储在 SQL Server CE 数据库中 C# Compact 框架代码
您好,我想使用 C# Compact 框架将图像插入数据库 SQL CE..
我的代码
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();
,但它显示错误.... openfiledialog1,找不到文件....
我的加载图像代码
openfiledialog open=new opendailog();
open.filter="Image Files(*.jpg*bmp;|*.jpg;*bmp;
if(open.showdilog()==dialogresult.Ok)
{
pitcherbox1.image=new bitmap(open.file);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您的错误消息来看,过滤器似乎无效。
尝试仅
*.jpg;*.bmp
From your error message it looks like the filter is invalid.
Try just
*.jpg;*.bmp