Error 3709 Visual Basic
Contents |
be..... If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. vb6 error 3709 To start viewing messages, select the forum that you want to visit from runtime error 3709 the selection below. Results 1 to 11 of 11 Thread: Run-time error '3709' The connection cannot be..... Tweet Thread Tools Show
Error 3709 The Search Key Was Not Found
Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Nov 23rd, 2010,03:00 PM #1 Patoh View Profile View Forum Posts Thread Starter Lively Member Join Date Nov
Error 3709 Access
2010 Posts 71 Run-time error '3709' The connection cannot be..... Hey people! Watsup! i need your help am getting a Run-time error '3709': (The connection cannot be used to perform this operation. Its either closed or invalid in this context) when this code tries to execute. Can anyone see the problem i have tried re writing the sql to no avail. please help Code: Private Sub lvButtons_H1_Click() Dim MyCon As error 3709 access 2010 New ADODB.Connection Dim MyRs As New ADODB.Recordset 3709 Error Code: MyRs.Open "SELECT plans.Number, plans.plan, patients.fname, patients.lname , plans.phone number, plans.card number, plans.vcode, plans.expiry FROM plans LEFT JOIN patients ON plans.payerid = patients.number WHERE plans.plan='" & Me.Combo1.Text & "'" With DataReport9.Sections("Section1").Controls 'section1 mean that section you create in datareport .Item("rptpayid").DataField = MyRs("payerid").Name .Item("rptplan").DataField = MyRs("plan").Name .Item("rptname").DataField = MyRs("fname").Name .Item("rptlname").DataField = MyRs("lname").Name .Item("rptphone").DataField = MyRs("phone number").Name .Item("rptcard").DataField = MyRs("card number").Name .Item("rptvcode").DataField = MyRs("vcode").Name .Item("rptexp").DataField = MyRs("expiry").Name End With Reply With Quote Nov 23rd, 2010,03:48 PM #2 RhinoBull View Profile View Forum Posts PowerPoster Join Date Mar 2004 Location New Amsterdam Posts 24,135 Re: Run-time error '3709' The connection cannot be..... You need to set connection/recordset object and also open connection before opening recordset. Try this instead but KIM that sample code below was not tested: Code: Private Sub Command1_Click() Dim strSQL As String Dim MyCon As ADODB.Connection Dim MyRs As ADODB.Recordset Set MyCon = New ADOB.Connection MyCon.Open "connection string goes here" Set MyRs = New ADODB.Recordset strSQL = "SELECT" & vbNewLine strSQL = strSQL & " plans.Number," & vbNewLine '<<< this field name may not be allowed as it could be reserved word strSQL = strSQL & " plans.plan," & vbNewLine strSQL = strSQL & " patients.fname," & vbNewL
Connection Run-time error ‘3709' ★★★★★★★★★★★★★★★ David Musgrave10 April 20132 0 0 0 It has been a long
Error 3709 The Connection Cannot Be Used
time since I shared a Quick Tip for Visual Basic for run time error 3709 the connection cannot be used Applications (VBA), but I have had this one waiting for me to write up for a while. runtime error 3709 in ms access When using VBA on a window with ActiveX Data Object (ADO) to connect to SQL Server to read and/or write data to tables, the best practice is http://www.vbforums.com/showthread.php?633744-Run-time-error-3709-The-connection-cannot-be to open the ADO connection on the Window_BeforeOpen() event and to close the ADO connectionusing the Window_AfterClose() event. This is similar to the best practice for reports discussed in theUsing ADO with VBA with Report Writerpost. There is one big difference in behaviour between windows and reports that can cause problems with this technique…. cue dramatic https://blogs.msdn.microsoft.com/developingfordynamicsgp/2013/04/10/quick-tip-vba-ado-connection-run-time-error-3709/ music….. Windows have a user interface which might cause a dialog to open and the window closure to be aborted. OK, big deal, why should this cause a problem for us? Well, let's work with the following scenario: The user opens the window and the Window_BeforeOpen() event opens the ADO connection. The user is working in the window and the VBA code is reading and writing via ADO as desired. The user is has finished editing data in the window (but has not saved) and closes the window. The "Do you want to Save, Discard or Cancel?" dialog opens and the user decides to cancel. The window closure is aborted and the window stays open. The user continues working and the next time VBA attempts to use ADO, the following error shows up: Run=time error ‘3709': Requested operation requires an OLE DB Session object, which is not supported by the current provider. So what happened? The issue here is that while theDexterity WIN_POS
8 Replies - 12763 Views - Last Post: 21 September 2012 - 07:19 AM Rate Topic: #1 thefifthhjohn New D.I.C Head http://www.dreamincode.net/forums/topic/289490-run-time-error-3709/ Reputation: 0 Posts: 11 Joined: 13-July 12 run time error 3709 Posted 20 August 2012 - 06:18 AM please help me I'm having error in rs.Open "SELECT * FROM [tbladmin] WHERE [username]= '" & txtUsername.Text & "'", con, adOpenStatic, adLockOptimistic I think my code is right I dunno where I went wrong. Dim strUserName As String, strPassword error 3709 As String Dim con As New ADODB.Connection Dim rs As New ADODB.Recordset Private Sub cmdlogin_Click() OpenCon rs.Open "SELECT * FROM [tbladmin] WHERE [username]= '" & txtUsername.Text & "'", con, adOpenStatic, adLockOptimistic If rs.RecordCount <> 0 Then If rs![Password] = txtPassword.Text Then If rs![user_type] = "Principal" Then MsgBox "The Principal has login", vbOKOnly + vbInformation, "LOGIN" frmMain.Transaction.Visible = error 3709 the True frmMain.Maintenance.Visible = True frmMain.Reports.Visible = True frmMain.Exit.Visible = True frmMain.Others.Visible = True frmMain.Files.Visible = True Login1 = 1 'frmMain.Text3 = Text1.Text 'frmMain.Text4 = TimeValue(Now) End If End If End If End Sub Attached image(s) Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: run time error 3709 #2 raziel_ Like a lollipop Reputation: 469 Posts: 4,265 Joined: 25-March 09 Re: run time error 3709 Posted 21 August 2012 - 12:42 PM the error says all. either you dont open your connection or the string for the connection is invalid. if you could show us the code where you open the connection we may give you better help Was This Post Helpful? 0 Back to top MultiQuote Quote + Reply #3 thefifthhjohn New D.I.C Head Reputation: 0 Posts: 11 Joined: 13-July 12 Re: run time error 3709 Posted 25 August 2012 - 06:53 PM raziel_, on 21 August 2012 - 12:42 PM, said:the error says all. either you dont open your c