Updating Record (via stored proc) with Blob Field using VB6

Updating Record (via stored proc) with Blob Field using VB6

Post by FS » Wed, 26 Jun 2002 09:05:26



I am trying to update a sqlserver record with a blob field using vb6.
I have the same functionality working with VB.net at this point and it works
fine.
All vb6 based samples I have looked at do not allow using the stored proc in
a similar fashion.
I would like to use the same stored proc from VB6 to add the record.
Please find below the code that I have working in VB.net.

I am looking for a similar approach (via same stored proc) using VB6.

Thank you in advance.

Fred
==================================================================

       Public Function Add_Recording(ByVal txtUserID As String, ByVal
SourceFilePath As String, ByVal longRecordingTime As Long) As Boolean
            Dim cn As New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
            Dim cmd As New SqlCommand("AddRecording", cn)
            ' Mark the Command as a SPROC
            cmd.CommandType = CommandType.StoredProcedure

            Dim fs As New System.IO.FileStream(SourceFilePath,
IO.FileMode.Open, IO.FileAccess.Read)
            Dim b(fs.Length() - 1) As Byte

            Try
                fs.Read(b, 0, b.Length)
                fs.Close()
            Catch
                Return False
            End Try

            ' Add Parameters to SPROC

SqlDbType.NVarChar, 20)
            parameterUserID.Value = txtUserID
            cmd.Parameters.Add(parameterUserID)

            'BLOB OBJECT
            Dim parameterBlobObject As New

            parameterBlobObject.Value = b
            cmd.Parameters.Add(parameterBlobObject)

            ' Add SECONDS Parameters to SPROC
            Dim parameterSeconds As New

            parameterSeconds.Value = longRecordingTime
            cmd.Parameters.Add(parameterSeconds)

            ' Add file size Parameters to SPROC

SqlDbType.BigInt, 64)
            parameterSize.Value = b.Length
            cmd.Parameters.Add(parameterSize)

            Try
                cn.Open()
                cmd.ExecuteNonQuery()
            Catch
                Return False
            End Try

            cn.Close()
            Return True

        End Function

 
 
 

Updating Record (via stored proc) with Blob Field using VB6

Post by Sukesh Hooga » Thu, 27 Jun 2002 13:36:45


FS

1) Instead of

CMD.PARAMETERS.ADD(xxx , etc.)

one has  has to use, as there is no ADD method for a parameter object in ADO
2.5  for VB6 (Not sure about VB.net)

CMD.PARAMETERS.APPEND SomeParam

In case of BLOBs, you will have to use

CMD.PARAMETERS.APPENDCHUNK SomeLargeData

2) You can try like this


adVarBinary,adParamInput, Size)


To retrieve you will have to use GetChunk method.

You can do the above  in smaller pieces of SomeLargeData

HTH

Sukesh

 
 
 

1. Insert/Updated to Image fields via Stored Proc

I have been experimenting with persisting a COM object's properties in a
image field using SQL Server 6.5. I have been sucessful, but only via ADO
AppendChunk() method. I was wondering if there is a way to pass this binary
data in via a stored procedure, instead of actually creating a recordset and
doing it via ADO AppendChunk(). It's not as simple as creating a parameter
of type image and passing in the variant data from my program is it? Thanks
in advance for any help!

Johnathan

2. Question regarding JDBC

3. Saving TMemo field data to a Blob field (Interbase Table) via SQL Update Query

4. dos client for nt 4.0

5. Using BLOBs (Byte) in VB6 via OLE DB to IDS 7.30

6. Oracle PL/SQL, Forms Developer, Airline Systems, UK

7. calling stored proc from stored proc via variable

8. HELP HELP HELP! Simple PL/SQL Problem !!!!?????

9. My textarea form field will not update my stored proc text field

10. Updating BLOB fields via SQL

11. Table Update Via Text File (DTS, Stored Proc, ActiveX, VBScript)

12. Storing BLOB fields via TQuery

13. Using a stored proc to call another stored proc