c#图片插入报错,解决了马上结在线 “图片”字段 在access里 设成“备注”,那么在sql server里使用二进制还是image呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在access 应该设置成 ole,在sql 应该使用二进制 楼上的 那个早改了,我是说数据库表的字段问题,谢谢clh111原来的图片字段是 image 16 改成binary 5000 后 提示要用convert函数转换的错误信息 于是又改回 image 16 ,运行结果出人意料:这次没有返回错误提示,而是回到操作成功界面shownews.aspx,但点击进入detailnews.aspx呈现图像错误显示的图标,(在测验数据的图片为空时,还都一切正常)我该怎么办? !全是眼泪! 我有自己做的代码(好使的)。[email protected] 还是那个问题,又困扰了我一上午,其他的功能还好的,唯独这个了 !全是眼泪!添加新闻页面,包括图片路径>>>点发表进入浏览新闻界面>>>点刚刚添加的新闻标题>>>进入浏览该条新闻:问题————显示图片的位置:呈现图像错误显示的图标 http://expert.csdn.net/Expert/topic/2493/2493940.xml?temp=.7637293image字段和其他字段不太一样,必须要申明一个变量 你的那问题就是如何使图片存库与读库,要用ole类型,同时使用Filestream来对图片进行处理,我以前就遇到过这样的问题,后来解决了,如下代码存库过程:string str=@"c:\mypicture.gif"; FileStream file = new FileStream(str,FileMode.Open, FileAccess.Read); Byte[] bytBLOBData = new Byte[file.Length]; file.Read(bytBLOBData, 0, bytBLOBData.Length); file.Close();OleDbCommand olecommand=new OleDbCommand("INSERT INTO 图表细节(图档内容) values(?)",oleDbConnection1);olecommand.Parameters.Add(new OleDbParameter("jpeg",OleDbType.Binary,bytBLOBData.Length,ParameterDirection.Input,true,0,0,null,DataRowVersion.Default,bytBLOBData));oleDbConnection1.Open();olecommand.ExecuteScalar();oleDbDataAdapter1.Update(ds1111);读库过程:byteBLOBData = (Byte[])(read["图档内容"]);MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);pictureBox1.Image=Image.FromStream(stmBLOBData);解决好了 .aspx 代码但在属性栏里没有Accept属性 是不是这里错了,那要如何改:<td width="73%">图片: <input id="File1" type=file Accept="Image/*" runat="server" NAME="File1">.cs 的这部分代码 ******SqlCommand myCommand = new SqlCommand("insert into tdnews (标题, 内文,zuozhe,开始日期,click,图片,重要性) values ('" + 标题.Text.ToString() + "', '" + 内文.Text.ToString() + "','" + zuozhe.Text.ToString() + "','" + DateTime.Now.ToString() + "',0,'" + Path.GetFileName(File1.PostedFile.FileName) + "','" + DropDownList2.SelectedItem.Value+ "')" , myConnection); myCommand.Connection.Open(); myCommand.ExecuteNonQuery(); myCommand.Connection.Close(); Response.Redirect("shownews.aspx") ; } } public void reset_Click(Object sender,EventArgs e) { 标题.Text=""; 内文.Text=""; zuozhe.Text=""; } 我用的是sqloledb全改成sql是吗 .aspx 代码<td width="73%">图片: <input id="File1" type=file Accept="Image/*" runat="server" NAME="File1">在属性栏里没有Accept属性 是不是这里错了,那要如何改: aforge.net导出视频和照片 C#编程 将图片插入word 怎么使图片衬于文字下方? c#中我生成项目时报错??? 菜鸟问题:帮忙解释一段代码。 请问:现在开发B/S最好用的开发工具是什么?C#ASP.NET怎么样?但对它如何部署不知道呀,别的工具呢?能提供些信息吗?谢谢!!! 菜鸟请教高手,关于字节数组的操作问题,在线等,急!!!! 怎么让文本框内容每次都添加到后边 GridView 超链接无法正常显示 问一个有关添加属性的问题! 关于事件 如何实现对象的值传递? 下面的5行代码完成了从局域网中找出所有的机器
谢谢clh111
原来的图片字段是 image 16 改成binary 5000 后 提示要用convert函数转换的错误信息
于是又改回 image 16 ,
运行结果出人意料:这次没有返回错误提示,而是回到操作成功界面shownews.aspx,但点击进入detailnews.aspx呈现图像错误显示的图标,(在测验数据的图片为空时,还都一切正常)
我该怎么办? !全是眼泪!
image字段和其他字段不太一样,必须要申明一个变量
存库过程:
string str=@"c:\mypicture.gif";
FileStream file = new FileStream(str,FileMode.Open, FileAccess.Read);
Byte[] bytBLOBData = new Byte[file.Length];
file.Read(bytBLOBData, 0, bytBLOBData.Length);
file.Close();
OleDbCommand olecommand=new OleDbCommand("INSERT INTO 图表细节(图档内容) values(?)",oleDbConnection1);
olecommand.Parameters.Add(new OleDbParameter("jpeg",OleDbType.Binary,bytBLOBData.Length,ParameterDirection.Input,true,0,0,null,DataRowVersion.Default,bytBLOBData));
oleDbConnection1.Open();
olecommand.ExecuteScalar();
oleDbDataAdapter1.Update(ds1111);
读库过程:
byteBLOBData = (Byte[])(read["图档内容"]);
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
pictureBox1.Image=Image.FromStream(stmBLOBData);
解决好了
<td width="73%">图片: <input id="File1" type=file Accept="Image/*" runat="server" NAME="File1">.cs 的这部分代码
******SqlCommand myCommand = new SqlCommand("insert into tdnews (标题, 内文,zuozhe,开始日期,click,图片,重要性) values ('" + 标题.Text.ToString() + "', '" + 内文.Text.ToString() + "','" + zuozhe.Text.ToString() + "','" + DateTime.Now.ToString() + "',0,'" + Path.GetFileName(File1.PostedFile.FileName) + "','" + DropDownList2.SelectedItem.Value+ "')" , myConnection);
myCommand.Connection.Open(); myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
Response.Redirect("shownews.aspx") ;
}
} public void reset_Click(Object sender,EventArgs e)
{
标题.Text="";
内文.Text="";
zuozhe.Text="";
}
oledb全改成sql是吗
<td width="73%">图片: <input id="File1" type=file Accept="Image/*" runat="server" NAME="File1">
在属性栏里没有Accept属性 是不是这里错了,那要如何改: