how to operate the image type data of SQL

sdming 2000-07-26 05:35:00
in vb program ,how to operate the image type data of SQL
...全文
161 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Wingsun 2000-08-02
  • 打赏
  • 举报
回复
你可以使用一个文件的方式来存取Image的数据,将Image的数据读取到一个Variant变量中去,然后就可以存取到数据库中去了.PictureBox对象也有一个Handle,这是它的句柄,你可通过它的句并获得他的数据,然后存储到数据库中。
sdming 2000-07-28
  • 打赏
  • 举报
回复
I will test,thank you
大虾今后多多指教!
sdming 2000-07-28
  • 打赏
  • 举报
回复
我知道这个MSDN上面的例子,但是
最根本的问题没有解决,怎么把图形赋给一个变量,然后调用上面的方法
Wingsun 2000-07-27
  • 打赏
  • 举报
回复
SQL不行,不过反正你用SQL都必须要用到RecordSet,通过他的Field不就可以了吗。
amstar 2000-07-27
  • 打赏
  • 举报
回复
在報表中怎么辦?
cobe 2000-07-27
  • 打赏
  • 举报
回复
如果我要用SQL语句,怎么写?
Wingsun 2000-07-27
  • 打赏
  • 举报
回复
使用Field字段的GetChunck和AppendChunck方法来存取Image类型字段。在程序中使用Byte类型数据来存取数据。
lczddd 2000-07-27
  • 打赏
  • 举报
回复
最好数据库中存取图片的地址,而不是图片本身,使用时根据地数据库中的地址找到
相应的图片即可
Wingsun 2000-07-27
  • 打赏
  • 举报
回复
AppendChunk 和 GetChunk 方法范例
该范例使用 AppendChunk 和 GetChunk 方法用其他记录中的数据填写图像字段。

Public Sub AppendChunkX()

Dim cnn1 As ADODB.Connection
Dim rstPubInfo As ADODB.Recordset
Dim strCnn As String
Dim strPubID As String
Dim strPRInfo As String
Dim lngOffset As Long
Dim lngLogoSize As Long
Dim varLogo As Variant
Dim varChunk As Variant

Const conChunkSize = 100

' 打开连接
Set cnn1 = New ADODB.Connection
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "
cnn1.Open strCnn

' 打开 pub_info 表。
Set rstPubInfo = New ADODB.Recordset
rstPubInfo.CursorType = adOpenKeyset
rstPubInfo.LockType = adLockOptimistic
rstPubInfo.Open "pub_info", cnn1, , , adCmdTable

' 提示复制徽标。
strMsg = "Available logos are : " & vbCr & vbCr
Do While Not rstPubInfo.EOF
strMsg = strMsg & rstPubInfo!pub_id & vbCr & _
Left(rstPubInfo!pr_info, InStr(rstPubInfo!pr_info, ",") - 1) & _
vbCr & vbCr
rstPubInfo.MoveNext
Loop
strMsg = strMsg & "Enter the ID of a logo to copy:"
strPubID = InputBox(strMsg)

' 将徽标复制到大块中的变量。
rstPubInfo.Filter = "pub_id = '" & strPubID & "'"
lngLogoSize = rstPubInfo!logo.ActualSize
Do While lngOffset < lngLogoSize
varChunk = rstPubInfo!logo.GetChunk(conChunkSize)
varLogo = varLogo & varChunk
lngOffset = lngOffset + conChunkSize
Loop

' 从用户得到数据。
strPubID = Trim(InputBox("Enter a new pub ID:"))
strPRInfo = Trim(InputBox("Enter descriptive text:"))

' 添加新记录,将徽标复制到大块中。
rstPubInfo.AddNew
rstPubInfo!pub_id = strPubID
rstPubInfo!pr_info = strPRInfo

lngOffset = 0 ' 重置位移。
Do While lngOffset < lngLogoSize
varChunk = LeftB(RightB(varLogo, lngLogoSize - lngOffset), _
conChunkSize)
rstPubInfo!logo.AppendChunk varChunk
lngOffset = lngOffset + conChunkSize
Loop
rstPubInfo.Update

' 显示新添加的数据。
MsgBox "New record: " & rstPubInfo!pub_id & vbCr & _
"Description: " & rstPubInfo!pr_info & vbCr & _
"Logo size: " & rstPubInfo!logo.ActualSize

' 删除新记录,因为这只是演示。
rstPubInfo.Requery
cnn1.Execute "DELETE FROM pub_info " & _
"WHERE pub_id = '" & strPubID & "'"

rstPubInfo.Close
cnn1.Close

End Sub
sdming 2000-07-27
  • 打赏
  • 举报
回复
怎样将图形赋给Byte类型的数据呢?
给个简单例子吧!
  • 打赏
  • 举报
回复
关注

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧