//将SQL server2000中保存的图像显示在Picture中
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
byte[] buffByte = null;
string comm = @"select img from table1 where id = " + this.listBox1.SelectedValue ;
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand ();
this.sqlCommand1.CommandType = System.Data.CommandType.Text ;
this.sqlCommand1.CommandText = comm;
this.sqlCommand1.Connection = this.sqlConnection1 ;
this.sqlConnection1.Open();
System.Data.SqlClient.SqlDataReader rd = this.sqlCommand1.ExecuteReader();
while (rd.Read())
{
buffByte = ((byte[])rd[0]);
}
rd.Close();
this.sqlConnection1.Close();
//将图像的字节数组放入内存流
System.IO.MemoryStream ms = new System.IO.MemoryStream(buffByte);
//通过流对象建立Bitmap
System.Drawing.Bitmap bmp = new Bitmap(ms);
this.pictureBox1.Image = bmp;
}
//将图像保存到SQL server2000的Image字段中
private void button2_Click_1(object sender, System.EventArgs e)
{
string pathName;
if (this.openFileDialog1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
pathName = this.openFileDialog1.FileName;
System.Drawing.Image img = System.Drawing.Image.FromFile(pathName);
this.pictureBox1.Image = img;
//将图像读入到字节数组
System.IO.FileStream fs = new System.IO.FileStream(pathName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
byte[] buffByte = new byte[fs.Length];
fs.Read(buffByte,0,(int)fs.Length);
fs.Close();
fs = null;
//建立Command命令
string comm = @"Insert into table1(img,name) values(@img,@name)";
this.sqlCommand1 = new System.Data.SqlClient.SqlCommand ();
this.sqlCommand1.CommandType = System.Data.CommandType.Text ;
this.sqlCommand1.CommandText = comm;
this.sqlCommand1.Connection = this.sqlConnection1 ;
//创建Parameter
this.sqlCommand1.Parameters.Add("@img",System.Data.SqlDbType.Image);
this.sqlCommand1.Parameters[0].Value = buffByte;
this.sqlCommand1.Parameters.Add("@name",System.Data.SqlDbType.VarChar);
this.sqlCommand1.Parameters[1].Value =pathName.Substring(pathName.LastIndexOf("\\")+1);
try
{
this.sqlConnection1.Open();
this.sqlCommand1.ExecuteNonQuery();
this.sqlConnection1.Close();
}
catch(System.Exception ee)
{
MessageBox.Show(ee.Message );
}
buffByte = null;
this.FillListBox();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
java毕业设计,包含完整前后端源码带数据库,项目可正常运行。 环境说明: 开发语言:Java 前端框架:小程序 JDK版本:JDK1.8 数据库:mysql 5.7+ 部署容器:tomcat7+ 数据库工具:Navicat11+ 开发软件:eclipse/myeclipse/idea(推荐idea) Maven包:Maven3.3.9 环境说明: 开发语言:Java 前端框架:小程序 JDK版本:JDK1.8 数据库:mysql 5.7+ 部署容器:tomcat7+ 数据库工具:Navicat11+ 开发软件:eclipse/myeclipse/idea(推荐idea) Maven包:Maven3.3.9
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计之在线错题管理系统的设计与实现源码.zip (345个子文件)
$PRODUCT_WORKSPACE_FILE$ 489B
AccountController.class 12KB
FileInfoController.class 9KB
AdminInfoController.class 8KB
UserInfoController.class 8KB
EchartsController.class 8KB
NxSystemFileController.class 8KB
AdvertiserInfoController.class 8KB
MenuController.class 4KB
AdminInfoService.class 4KB
UserInfoService.class 4KB
FileInfo.class 3KB
AdminInfo.class 3KB
AdvertiserInfoService.class 3KB
FileInfoService.class 3KB
UserInfo.class 3KB
Account.class 3KB
NxSystemFileInfoService.class 3KB
Result.class 2KB
EchartsData.class 2KB
ResultCode.class 2KB
MyInterceptor.class 2KB
GlobalExceptionHandler.class 2KB
EchartsData$Data.class 2KB
WebMvcConfig.class 2KB
AdvertiserInfo.class 2KB
EchartsData$Series.class 1KB
AuthorityInfo.class 1KB
MyInterceptorConfig.class 1KB
NxSystemFileInfo.class 1KB
AuthorityInfo$Model.class 1KB
CustomException.class 1KB
FileInfoDao.class 1KB
AdminInfoDao.class 920B
UserInfoDao.class 915B
Application.class 793B
NxSystemFileInfoDao.class 773B
AdvertiserInfoDao.class 649B
AdvertiserInfoVo.class 320B
AdminInfoVo.class 300B
UserInfoVo.class 296B
FileInfoVo.class 296B
index.css 227KB
index.css 227KB
index.css 227KB
index.css 227KB
bootstrap.min.css 119KB
bootstrap.min.css 119KB
bootstrap.css 115KB
bootstrap.css 115KB
font-awesome.css 28KB
font-awesome.css 28KB
quill.snow.css 24KB
quill.snow.css 24KB
font-awesome.css 21KB
font-awesome.css 21KB
bootstrap-theme.min.css 19KB
bootstrap-theme.min.css 19KB
swiper.min.css 13KB
swiper.min.css 13KB
custom-styles.css 10KB
custom-styles.css 10KB
nav.css 1KB
nav.css 1KB
my.css 1KB
my.css 1KB
index.css 480B
index.css 480B
notice.css 475B
notice.css 475B
fontawesome-webfont.eot 55KB
fontawesome-webfont.eot 55KB
fontawesome-webfontd41d.eot 37KB
fontawesome-webfontba72.eot 37KB
fontawesome-webfontd41d.eot 37KB
fontawesome-webfontba72.eot 37KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regulard41d.eot 20KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regulard41d.eot 20KB
my.log.2021-04-16.0.gz 3KB
fileInfo.html 25KB
fileInfo.html 25KB
chutiInfo.html 21KB
chutiInfo.html 21KB
adminInfo.html 20KB
adminInfo.html 20KB
userInfo.html 20KB
userInfo.html 20KB
advertiserInfo.html 18KB
advertiserInfo.html 18KB
fileInfoDetail.html 15KB
fileInfoDetail.html 15KB
accountAdminInfo.html 12KB
accountAdminInfo.html 12KB
accountUserInfo.html 11KB
accountUserInfo.html 11KB
index.html 11KB
共 345 条
- 1
- 2
- 3
- 4
资源评论
大学生资源网
- 粉丝: 138
- 资源: 1334
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功