用后台向数据库提交图片进行存储 用SQL数据库的什么数据类型??
最好是vb或者vb.net写的,有代码最好拉,多谢多谢,最好里面有注释讲讲,谢谢谢谢!!

解决方案 »

  1.   

    《求救!asp.net+c#上传图片到access数据库及显示图片的代码?》
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=185154
      

  2.   

    参见:
        孟子E章
        向SQL Server数据库添加图片
        http://dotnet.aspx.cc/ShowDetail.aspx?id=2A5DD7C6-A45A-48AB-A2E8-342A29F17506
      

  3.   

    Private Sub Read(ByVal spath As String)
            Dim zsr As String
            If Tzsr = "" Then
                zsr = "0"
                Page.RegisterStartupScript("dgscript", "<script Language=""Javascript"">alert('主送人为必添的数据,否则无法进行提交')</script>")
                Exit Sub
            Else
                zsr = "," & TzsrID
            End If
            Dim zfbgs As Int16
            If Drpple.SelectedItem.Text = "办公室" Then
                zfbgs = 1
            Else
                zfbgs = 0
            End If
            Dim zz As Integer
            If td11.Text = "" Then
                zz = 0
            Else
                zz = CInt(Me.td11.Text)
            End If
            Dim strUp As String = "INSERT INTO  B_wjcs  (名称,标题,主送人,抄送人,抄送日期,审核,会签人,签发人,打印人,校对,印数,办公室,印发日期,文件名,文件类型)" _
            & "VALUES ('" & td1.Text & "','" & td2.Text & "','" & zsr & "','" & td4.Text & "','" & LXdatetime & "','" _
            & td6.Text & "','" & td7.Text & "','" & td8.Text & "','" & td9.Text & "','" & td10.Text & "'," & zz & ",'" & zfbgs & "','" & JZdatetime _
            & "','" & FileName & "','" & size & "')     select top 1 @@IDENTITY from B_wjcs "
            Dim cm As New SqlClient.SqlCommand(strUp, Sqlcon)
            cm.Connection.Open()
            Dim xmid As Integer = cm.ExecuteScalar
            cm.Dispose()
            Sqlcon.Close()
            '在B_wjcs表内插入
            Dim count As Integer
            Dim offset = 1048576
            Dim MyStream As System.IO.Stream
            Dim Input(offset - 1) As Byte
            MyStream = UploadFile.PostedFile.InputStream
            Dim i As Integer = 0
            Dim str As String = ""
            MyStream.Position = 0
            Sqlcon.Open()
            Do
                count = MyStream.Read(Input, 0, offset)
                If count <> offset Then
                    ReDim Preserve Input(count - 1)
                End If
                i += 1
                str = "  INSERT INTO B_WjCs_Wj (文件ID,编号,内容) VALUES(" & xmid & "," & i.ToString & ",@ww) "
                cm = New SqlClient.SqlCommand(str, Sqlcon)
                cm.Parameters.Add(New SqlClient.SqlParameter("@ww", SqlDbType.Image)).Value = Input
                cm.ExecuteNonQuery()
                cm.Dispose()
            Loop While count = offset
            Sqlcon.Close()
            MyStream.Close()
        End Sub
      

  4.   

    以上是 存储 二进制文件的代码,它将二进制文件转换成数据流的形式,1m为一个包上传到B_WjCs_Wj 表的‘内容’字段,B_WjCs_Wj是 B_wjcs  它的外表。