How to upload Image from client into SQL Server 7.0

I would like to ask the Expert a question that i want to make an Client/Server APP in VB6 in order to saving my picture from client into SQL Server 7.0 database . I have known the main method is using ADO (appendchunk) but please give a clear example already rung well .

Thank you very much in advance
lethanhhaiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sidcapCommented:
lethanhhai:

Just go at http://support.microsoft.com/support/kb/articles/q194/9/75.asp?FR=0

Hope this helps, SIDCAP.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kal_judaiaCommented:
Private Function GetRandomFileName(sDirTarget As String, _
                                   sPrefix As String, _
                                   sExtention As String) As String

'Generates a unique temp file name for the specified directory
'with the specified extention
On Error Resume Next
Dim fs As FileSystemObject   ' **** requires filesystem object
Dim sFName As String
Dim iRnd As Long
Dim iUpperBound As Long, iLowerbound As Long

TRYAGAIN:

Randomize
iUpperBound = 99
iLowerbound = 0
iRnd = Int((iUpperBound - iLowerbound + 1) * Rnd + iLowerbound)

sFName = CStr(iRnd) + CStr(DatePart("d", Now())) _
                    + CStr(DatePart("h", Now())) _
                    + CStr(DatePart("n", Now()))

sFName = sPrefix + sFName + "." + sExtention

Set fs = New FileSystemObject

If Not fs.FileExists(sDirTarget + "\" + sFName) Then
    GetRandomFileName = sDirTarget + sFName
    Exit Function
Else
    GoTo TRYAGAIN
End If

End Function

Public Function CopyImageField(fld As ADODB.Field, _
                               fldTO As ADODB.Field)

'This function takes the source field image and copies it
'into the destination field.
'The function first saves the image in the source field to a
'temp file on disc. Then reads this temp file into
'the destination field.
'The temp file is then deleted
On Error Resume Next

Dim iFieldSize  As Long
Dim varChunk    As Variant
Dim baData()    As Byte
Dim iOffset     As Long
Dim sFName      As String
Dim iFileNum    As Long
Dim cnt         As Long
Dim z()         As Byte

Const CONCHUNKSIZE As Long = 16384

Dim iChunks As Long
Dim iFragmentSize As Long
   
    'Get a unique random filename
    sFName = GetRandomFileName(App.Path, "pic", "tmp")
   
    'Open a file to output the data to
    iFileNum = FreeFile
    Open sFName For Binary Access Write Lock Write As iFileNum
   
    'Copy the logo to a variable in chunks.
    iFieldSize = fld.ActualSize
    iChunks = iFieldSize / CONCHUNKSIZE
    iFragmentSize = iFieldSize Mod CONCHUNKSIZE
    If iFragmentSize > 0 Then
' if there is a frag then write it first, else just use chunk
        ReDim baData(iFragmentSize)
        baData() = fld.GetChunk(iFragmentSize)
        Put iFileNum, , baData()
    End If
   
    'Fragment added; Now write rest of chunks
    ReDim baData(CONCHUNKSIZE)
    For cnt = 1 To iChunks
        baData() = fld.GetChunk(CONCHUNKSIZE)
        Put iFileNum, , baData
    Next cnt
   
    'Close file
    Close iFileNum
   
    'Now we have the file on disk Load the pic from
    'the temp file into the other field
   
    Open sFName For Binary Access Read As #1
    ReDim z(FileLen(sFName))
    Get #1, , z()
    fldTO.AppendChunk z
    Close #1
   
    'Delete the file
    Kill (sFName)
   
End Function

0
lethanhhaiAuthor Commented:
Excellent
Thank you very much
Can you give me your email address
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.