Manish Patat

Manish Patat

  • 1.7k
  • 68
  • 7.6k

Visual Basic .net Using Filestream SQL In insert Update Select

Jul 24 2021 11:13 AM

I have Use SQL Server 2014 in My Database Filestream Data 

Save Data Query

 If FilePath1 <> "" Then
                Query = "Select bulkcolumn  From OPENROWSET(BULK '" & FilePath1 & "',SINGLE_BLOB ) AS Doc"
                RS.Open(Query, CN)
                If RS.EOF = True And RS.BOF = True Then
                    RS.Close()
                    A2 = ""
                Else
                    A2 = RS.Fields(0).Value.ToString
                    RS.Close()
                End If
            End If

 Query = "SET DATEFORMAT DMY Insert Into TDCWax (TDCNo,ID,ImgA1" _
                & ")VALUES('" & TxtTDCNo.Text & "',NEWID(),Cast('" & A1 & "' as  VARBINARY(Max)))"
            CN.Execute(Query)

Save Complete Data And Set Path Filestream Create Folder And File Save

But I Have Retrive Data his Code Here

Dim TDCImg1() As Byte
                Query = "Select TDCNO,ImgA1 from TDCwax Where TDCNo='" & TxtTDCNo.Text & "'"
                RS.Open(Query, CN)
                If RS.EOF = True And RS.BOF = True Then
                    RS.Close()
                Else

                    Txttdcno.text= RS.Fields(0).Value
                    TDCImg1 = RS.Fields(1).Value
                    RS.Close()
                    Dim ms As New MemoryStream(TDCImg1)
                    PCT1.Image = System.Drawing.Image.FromStream(ms)
                End If

But My PCT1 is picture box Not Show Image And Error {"Parameter is not valid."}

Thanks and Advance 


Answers (1)