Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003

    Unanswered: getting image data from SQL Server into VB

    Respected Sir,
    I have my data base in microsoft sql server and front end is VB.Sir plese give me the example code to access the image data type from SQL Server into Visual Basic 6.0.

  2. #2
    Join Date
    Sep 2003

    Talking pushing and fetching data from sql server

    i have this code just try it out, you will have to make changes at places.
    it fetches and pushes data to sql database

    *****************PUSHING DOCUMENT TO DATABASE*****************************
    Dim datafile As Integer, Fl As Long, F2 As Long, chunks As Long
    Dim fragmenT As Integer, chunk() As Byte
    Const chunksize As Long = 16384
    Dim ChunkSi As Long
    Dim filename1 As String

    Dim str1 As String
    Set Rs = Nothing
    Rs.Open "select * from tblGoodsComparission", Cn, adOpenStatic, adLockOptimistic
    Rs("RFPNo") = cmbRFPNo.Text
    Rs("ComparissionDate") = Now
    Rs("TechComment") = Replace(txtTechComment.Text, "'", "''")
    Rs("FinComment") = Replace(txtFinComment.Text, "'", "''")
    Rs("FinalVendor") = cmbIndex.Text
    Rs("FinalCoast") = txtRate.Text

    ' filename1 = App.Path & "\" & strUserName & "Save.xls"
    filename1 = commondialog1.filename

    datafile = FreeFile
    Open filename1 For Binary Access Read As datafile
    Fl = LOF(datafile) ' Length of data in file
    If Fl = 0 Then Close datafile: Exit Sub
    ChunkSi = Fl / 4
    chunks = Fl / ChunkSi 'chunksize
    fragmenT = Fl Mod chunksize
    ReDim chunk(fragmenT)
    Get datafile, , chunk()
    Rs("Comparission").AppendChunk (chunk())
    ReDim chunk(ChunkSi)
    For j = 1 To chunks
    Get datafile, , chunk()
    Rs("Comparission").AppendChunk (chunk())
    Next j
    Close datafile

    ' Kill App.Path & "\" & strUserName & "Save.xls"
    Kill commondialog1.filename

    **********PUSHING DOCUMENT TO DATABASE OVER HERE*********************

    ********* FETCHING DOCUMENT FROM DATABASE****************************
    Rs.Open "Select * From tblServiceComparission where RFPNo='" & Label10.Caption & "'", Cn, adOpenStatic
    If Rs.RecordCount <> 0 Then
    filename1 = App.Path & "\ComparativeStatement.xls"
    Fl = Rs("Comparision").ActualSize
    chunksize = Rs("Comparision").ActualSize
    If chunksize > 0 Then
    datafile = FreeFile
    Open filename1 For Binary Access Write As datafile
    chunk1() = Rs("Comparision").GetChunk(chunksize)
    Put datafile, , chunk1()
    Close datafile
    End If
    ************FETCHING DOCUMENT FROM DATABASE OVER HERE************************

    enjoy dude.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts