| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 587 人关注过本帖
标题:sql2000保存图片怪象
只看楼主 加入收藏
hpu02zdh
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-5-12
收藏
 问题点数:0 回复次数:2 
sql2000保存图片怪象

我用的是2005版本的编程软件 可是有一句sqlCmd.Parameters.Add("@IMAGE", buffer)出现警告,请高手指点
Private Sub InsertData()
Dim IDItem(2) As String
IDItem = CmbStuClass.Text.Split(":"c)

Dim StuID As Int16 = Int16.Parse(TxtStuID.Text.Trim)
Dim StuName As String = TxtStuName.Text.Trim
Dim StuSex As String = CmbStuSex.Text.Trim
Dim StuClass As String = IDItem(0)
Dim StuBirthday As Date = DateStuBir.Value
Dim StuCard As String = TxtPerCard.Text
Dim StuPhoto As String = LblPhotoPath.Text.Trim


Dim MyStream As New FileStream(StuPhoto, FileMode.Open, FileAccess.Read)
Dim buffer(MyStream.Length) As Byte
MyStream.Read(buffer, 0, MyStream.Length)
MyStream.Close()


Dim value As String = StuID.ToString + ",'" + StuName + "','" + StuSex + "'," + StuClass + ",'" + StuBirthday + "','" + StuCard + "'"

Dim sql As String = "INSERT INTO STUDENTINFO (STUDENTID, STUDENTNAME,SEX,CLASSID,BIRTHDAY,PERSONCARDID,STUDENTPHOTO) VALUES(" + value + ", @IMAGE)"

Dim sqlCmd As New SqlCommand
sqlCmd.CommandText = sql
sqlCmd.Parameters.Add("@IMAGE", buffer)
sqlCmd.Connection = SqlCon

Try
SqlCon.Open()
sqlCmd.ExecuteNonQuery()
MessageBox.Show("添加记录成功")
Catch ex As Exception
MessageBox.Show("添加记录失败")
WriteErr(ex)
Finally
SqlCon.Close()
End Try
BindData()
End Sub

搜索更多相关主题的帖子: 保存 
2007-06-07 11:55
frxyrx
Rank: 1
等 级:新手上路
威 望:1
帖 子:66
专家分:0
注 册:2006-11-2
收藏
得分:0 
sqlCmd.Parameters.Add("@image", SqlDbType.Image).Value = buffer
用这个试试

2007-06-07 16:44
hpu02zdh
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2007-5-12
收藏
得分:0 

谢谢!
问题解决了

2007-06-07 19:22
快速回复:sql2000保存图片怪象
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017036 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved