Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2006, 06:55 PM
Registered User
 
Join Date: Jul 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default recordset open error

hi,i have a listbox which i'm facing problems with in storing its contents to its respective field in the database.code is as below, however an error occurred where it reads 'rs2.Open' statin that 'method or data member not found'...any help on this part? by the way, this is where i'm adding new records to my database.

Code:
Private sub cmdAdd_click()
Dim rs2 As Recordset
Dim strMyStr As String
Dim conn As New ADODB.Connection
Dim sSQL As String, sConn As String
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\legalminder1.mdb;Persist Security Info=False"

'        Set wk2 = DBEngine.CreateWorkspace("MyWks", "admin", "", dbUseJet)
'        Set db2 = wk2.OpenDatabase("c:\Project 1\legalminder1.mdb", False)
'       Set rs2 = db2.OpenRecordset("addrecord", dbOpenDynaset)
        On Error GoTo errHnd
 
        sSQL = "SELECT * FROM addrecord"
        Set conn = New ADODB.Connection
        'con.ConnectionString = sConn
        conn.Open sConn
        Set rs2 = New ADODB.Recordset
        rs2.Open sSQL, conn, adOpenStatic, adLockOptimistic

'        MsgBox "Add Record", vbInformation, "Record"
'        now we can add the record
        rs2.AddNew

        rs2.Fields(1).Value = UCase(txtDefineTask.Text)
        rs2.Fields(2).Value = UCase(txtDocuments.Text)
        rs2.Fields(3).Value = DTPicker1.Value
        rs2.Fields(4).Value = CInt(txtDays.Text)
        rs2.Fields(5).Value = UCase(txtNotes.Text)
'        here we first need to create a string
        rs2.Fields(6).Value = GetListItems()

        rs2.Update
'        lstAttach.AddItem NoNull(rs2.Fields(6).Value)

        txtDefineTask = ""
        txtDocuments = ""
        DTPicker1.Value = Date
        txtDays = ""
        txtNotes.Text = ""
        lstAttach.Clear
        txtDefineTask.SetFocus
        ' when we reach this point without any error we can do this msg
        MsgBox "Record added Successfully", vbInformation, "Record"
    End If

LeavePoint:
' The connection needs to be closed in any case- so we add this lines
    If rs2.State = adStateOpen Then
        rs2.Close
        Set rs2 = Nothing
    End If
    If conn.State = adStateOpen Then
        conn.Close
        Set conn = Nothing
    End If
    Exit Sub
errHnd:             ' this is the entry point for errorhandler
    Call MsgBox(Err.Description, vbCritical + vbOKOnly, "Storing Data failed")
Err.Clear
GoTo LeavePoint ' also closing connection in errorcase

 End Sub


 
Old September 3rd, 2006, 11:11 PM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 180
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via ICQ to dpkbahuguna Send a message via MSN to dpkbahuguna Send a message via Yahoo to dpkbahuguna
Default

Frnd I think you forgot to use the ADODB Class in initialization

like,

   Dim rs2 As ADODB.Recordset = Dim rs2 As Recordset

DPK..
 
Old September 4th, 2006, 04:52 PM
Registered User
 
Join Date: Jul 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey thanks, got that!






Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB.Recordset error lance Wrox Book Feedback 2 February 23rd, 2007 02:37 PM
Get the error "ADODB.Recordset error '800a0e7d' " Raymond Classic ASP Databases 2 August 5th, 2006 03:53 PM
Recordset Error malhyp Dreamweaver (all versions) 3 December 21st, 2005 05:06 PM
Please on help recordset can't open mars1009 Classic ASP Databases 2 November 15th, 2004 02:43 AM
Recordset error lance Access ASP 1 February 17th, 2004 07:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.