//将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();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
(基于mysql的Java毕业设计)在线错题管理系统(源码) 【项目技术】 开发语言:Java 数据库:mysql 【实现功能】 管理员登录进入在线错题管理系统可以查看首页、信息管理、修改密码和退出登录等内容
资源推荐
资源详情
资源评论
收起资源包目录
(基于mysql的Java毕业设计)在线错题管理系统(源码).rar (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
FileInfoVo.class 296B
UserInfoVo.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
file-info 0B
file-info 0B
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
共 345 条
- 1
- 2
- 3
- 4
资源评论
岛上程序猿
- 粉丝: 2105
- 资源: 3506
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 3_总店400-50.psd
- 图像超分辨率领域基准测试集Urban100
- 968051697825500漫画园.apk
- mybatis 动态sql内容讲解及笔记
- 基于Python天气动态大屏代码和数据(可做毕设/课设)
- .NET框架的身份管理和认证-Identity框架
- 图像超分辨率基准数据集
- VB6.0Access进销存信息管理系统.7z
- MATLAB是由美国MathWorks公司开发的一款商业数学软件,被誉为“矩阵实验室” 它集成了数值分析、矩阵计算、科学数据可视
- 数据库课程设计通常包括一系列的教学资源和材料,这些资源旨在为学生提供全面的学习支持 首先,课程通常提供一套完整的教材或讲义,介绍
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功