最好在前台做!在SQL里:create table # (a text)insert # values('asdfasdfiewrhjtoigk;jhdsaloihvbdiouvdsigdfgttyjudgufyufyudrtyesryreyluhglseiuhtldskhglksdhguidsfvbludshgkdhf')DECLARE @ptrval varbinary(16),@len int
SELECT @ptrval = TEXTPTR(a),@len=datalength(a)-1 FROM #
READTEXT #.a @ptrval 1 @len
drop table #

解决方案 »

  1.   

    vb:Private Sub LoadPictureFromDB(cn As ADODB.Connection)
    '载数据库中读出BMP图片
    On Error GoTo EH
        Dim strTemp As String
        Set stm = New ADODB.Stream
        strTemp = "c:\temp.tmp" '临时文件,用来保存读出的图片
        rs.Open "select ImagePath,ImageValue  from tbl_image", cn, , , adCmdText
        With stm
            .Type = adTypeBinary
            .Open
            .Write rs("ImageValue")
            .SaveToFile strTemp, adSaveCreateOverWrite
            .Close
        End With
        Image1.Picture = LoadPicture(strTemp)
        Set stm = Nothing
        rs.Close
        Set rs = Nothing
    Exit Sub
    EH: MsgBox Err.Description, vbInformation, "Error"
    End Sub
      

  2.   

    pengdali(大力),怎末把byte数组给放到数据库中呀? yoki(小马哥),是这样的
                   前台用Vb做界面后台用C#读取数据库
                   前台把word文档(含图片)给我时
                   传参传的就是byte数组,然后我在c#里把它放到数据库里
                   取也是我在C#里把它从数据库中取出放到byte数组中
                   再传给vb
      

  3.   

    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim stm As ADODB.StreamPrivate Sub SavePictureToDB(cn As ADODB.Connection)
    '将BMP图片存入数据库
    On Error GoTo EH
        Set stm = New ADODB.Stream
        rs.Open "select ImagePath,ImageValue from tbl_Image", cn, adOpenKeyset, adLockOptimistic
        CommonDialog1.ShowOpen
        Text1.Text = CommonDialog1.FileName
        
        With stm
             .Type = adTypeBinary
             .Open
             .LoadFromFile CommonDialog1.FileName
        End With
        With rs
             .AddNew
             .Fields("ImagePath") = Text1.Text
             .Fields("ImageValue") = stm.Read
             .Update
        End With
        rs.Close
        Set rs = Nothing
    Exit Sub
    EH: MsgBox Err.Description, vbInformation, "Error"
    End Sub
    ?????
      

  4.   

    我知道vb里咋做
    可是C里#怎末做呢?
    C#里有一个system.data.sqltypes.sqlbiny的东西
    不知是不是类似vb的adodb.stream
    可是这个东西也没有读写的方法
    还请大虾指点一下,在c#里从数据库读写byte数组