Results 1 to 3 of 3

Thread: database problem (ole)

  1. #1

    Thread Starter
    Fanatic Member vivek_master146's Avatar
    Join Date
    Apr 2006
    Location
    Delhi,India
    Posts
    787

    Unhappy database problem (ole)

    Option Explicit

    Public connString As String
    Public connMain As New ADODB.Connection
    Public rs As ADODB.Recordset
    Public htmTitle As String
    Dim pBag As PropertyBag
    Dim pByteA() As Byte

    Private Sub Command1_Click()
    loadRecord Text1.Text
    End Sub

    Private Sub Command2_Click()
    CommonDialog1.ShowOpen
    Media1.FileName = CommonDialog1.FileName
    Media1.Play
    End Sub

    Private Sub Command3_Click()
    Dim strQuery

    'Create propertybag
    Set pBag = New PropertyBag

    'Write object
    pBag.WriteProperty "Myvideo", Media1

    'Fill array with binary data of pic
    pByteA = pBag.Contents

    'Write data to database
    'strQuery = "INSERT INTO Employees (emppic) VALUES (" & pByteA & ")"
    'connMain.Execute strQuery

    rs.AddNew
    rs.Fields("datas").Value = pByteA
    rs.Update
    End Sub

    Private Sub Form_Load()
    connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\my documents\ghfr.mdb;Persist Security Info=False;"
    connMain.Open connString

    Set rs = New ADODB.Recordset
    rs.Open "viveks", connMain, adOpenKeyset, adLockPessimistic, adCmdTable
    End Sub

    Private Sub loadRecord(strkey As String)
    Dim strQuery As String
    Dim objRs As Recordset

    Set objRs = New ADODB.Recordset

    strQuery = "Select * from viveks where empid = " & strkey
    objRs.Open strQuery, connMain

    On Error Resume Next
    pByteA = objRs.Fields("datas").Value
    Set pBag = New PropertyBag
    pBag.Contents = pByteA
    Set Media1 = pBag.ReadProperty("Myvideo")

    objRs.Close

    End Sub

    The code is not working. I am trying to save a .avi to database but it is showing error.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: database problem (ole)

    what line does the error occur on?

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: database problem (ole)

    Also use the VBCODE tags for your code to make it more readable.

Posting Permissions

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



Click Here to Expand Forum to Full Width