⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmsetup.frm

📁 LOB objects for oracle database,inserting them to database
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmSetup 
   Caption         =   "Setup Form"
   ClientHeight    =   5190
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7320
   LinkTopic       =   "Form1"
   ScaleHeight     =   5190
   ScaleWidth      =   7320
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdPopulate 
      Caption         =   "Populate Data"
      Height          =   615
      Left            =   2400
      TabIndex        =   0
      Top             =   2880
      Width           =   2175
   End
   Begin VB.Label lblHeading 
      Caption         =   "Populate LOB Data "
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   21.75
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   855
      Left            =   1800
      TabIndex        =   1
      Top             =   840
      Width           =   4215
   End
End
Attribute VB_Name = "frmSetup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*******************************************************************************
' @author   Jagriti
' @version  1.0
'
' Development Environment       : MS-Visual Basic 6.0
' Name of the Application       : setupLOB.vbp
' Creation/Modification History :
'
' Jagriti       03-Aug-2001       Created
'
' Overview of Application       :
' This application is a part of setup for the OLEDB samples.
' It is used to populate data in the Product_Image column of the
' Product_Information database table. The Product_Image column is of BLOB datatype.
' The images are provided within the zip file of the sample.
' The BLOB data is used in the samples like
' 1. Passing LOB parameter to a database stored procedure sample.
' 2. Immediate update sample.
' 3. Chunk Size Property versus Value Property sample.
' 4. Passing LOB Parameter with OraOLEDB sample (VC++ 6.0).
' 5. Passing LOB Parameter with OraOLEDB sample (VC Sharp).
' 6. Passing LOB Parameter with OraOLEDB sample (Using OLEDB interfaces with VC++ 6.0).
' This application should be run after running the script Ora8OLEDBScript.sql
'
' Note: That product_ids have been hardcoded in this form and the Product_Images
'       supplied with this form in the images folder have been named corresponding
'       to their Product Ids. In case Product IDs or Image names are changed then
'       this application will not work. So in case changes are required then
'       change the Product Ids and images accordingly.
'*******************************************************************************

'*******************************************************************************
' This sub procedure is used to populate LOB data in the Product_Information's
' Product_Image column. The column initially has Empty_BLOB(), by clicking
' the "Populate Image" button it picks up the product images from the images
' folder in the current application path. And opens a recordset with few product IDs
' from the Product_Information table. The Product_Images are named same as
' Product Id, for eg. ProductId "3050", Image Name is named as "3050.gif".
'*****************************************************************************

Private Sub cmdPopulate_Click()

Dim Oracon As New ADODB.Connection  'connection object

'recordset with product_id and product_image
Dim recProductInformation As New ADODB.Recordset

Dim bytchunk() As Byte 'variable to hold binary array
Dim FileNum As Integer 'variable for file number

'variable to the current product_id value from the recordsetwhile fetching images.
Dim curProductId  As Integer


On Error GoTo ErrorText 'redirect to error handler

'setting mouse pointer on the form "frmSetup" to wait state
frmSetup.MousePointer = vbHourglass

'set connection parameters in connectionParams.bas module
connectionParams.setparams
  
Set Oracon = CreateObject("ADODB.Connection") 'creates a connection object
 
'setting information for establishing connection
Oracon.Provider = "OraOLEDB.Oracle"
 
'get the connection parameters from "connectionParams.bas" module
Oracon.ConnectionString = "Data Source=" + connectionParams.datasource & _
                          ";User ID=" + connectionParams.username & _
                          ";Password=" + connectionParams.password
   
Oracon.Open 'establishing connection to the datasource


'open recordset with product_id, product_image columns from product_information
'table using m_Oracon connection.
'"adOpenKeyset" cursor type used to allow all types of movements through the recordset
recProductInformation.Open "SELECT product_id, product_image " & _
                           " FROM product_information WHERE product_id IN " & _
                           " (3060, 3057, 2252, 3350, 2459, 2254, 2253, 3072, " & _
                           " 3071, 1743, 3073, 2410, 1797, 2453, 2255, 3155) " _
                           , Oracon, adOpenKeyset, _
                           adLockOptimistic, adCmdText

'fetching records from recordset and populating the combobox
Do While Not recProductInformation.EOF
  
  'assigning next file number available for use
  sourceFileNum = FreeFile
  
  'assign the current product_id
  curProductId = recProductInformation!product_id
 
  'open the file selected from common dialog for reading
  Open App.Path & "\images\" & curProductId & ".gif" For Binary As sourceFileNum
  
  'using reDim statement to reallocate storage space for bytChunk array variable
  'to the length of the file selected from the common dialog
  ReDim bytchunk(LOF(sourceFileNum))
 
  'reads data from the file selected from the fileopen dialog box to bytChunk variable
  Get #sourceFileNum, , bytchunk()
 
  'Close the opened file handle
  Close #sourceFileNum
  

  'write the image converted into byte array to the product_image
  'field of the recordset
  recProductInformation!product_image.AppendChunk bytchunk
 

  'saves the changes made to the recordset
  recProductInformation.Update
  
  'move the recset cursor to next record
  recProductInformation.MoveNext
  
Loop

'setting mouse pointer on the form "frmSetup" to Normal state
frmSetup.MousePointer = vbNormal

MsgBox "Images updated successfully!"
     
'close the recordset and free the memory held by it
recProductInformation.Close
Set recProductInformation = Nothing
    
    
'close the connection and free the memory held by it
Oracon.Close
Set Oracon = Nothing
     
     
If (Not Err.Number = 0) Then
ErrorText:      'error handler
  MsgBox "Source :" + Err.Source + " Description :" + Err.Description, , "Error"
End
End If
     
End Sub


Private Sub Form_Load()

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -