Error 3709 Visual Basic 6.0
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ VB6 run-time error 3709 the connection cannot be used to perform the operation-it is either closed or invalid Rate this: Please Sign up or sign in to vote. See more: VB6 I always get this error everytime I ran the program. Dim rs As New ADODB.Recordset rs.Open "Select * From tbluser Where uname = '" & txtuser.Text & "'", cnn, adOpenStatic, adLockReadOnly If rs.RecordCount < 1 Then MsgBox "Invalid Username!", vbCritical, "Login Error" txtuser.SetFocus Exit Sub Else If txtpass.Text = rs!pword Then Unload Me Load Form2 Form2.Show Exit Sub Else MsgBox "Invalid Password!", vbCritical, "Login Error" txtpass.SetFocus Exit Sub End If End If Set rs = Nothing MODULE CODE: Option Explicit Public cnn As ADODB.Connection Public Sub getconnected() Set cnn = New ADODB.Connection cnn.CursorLocation = adUseClient cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database1.mdb" &
8 Replies - 12766 Views - Last Post: 21 September 2012 - 07:19 AM Rate Topic: #1 thefifthhjohn New D.I.C Head 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 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] http://www.codeproject.com/Questions/557798/VB-plusrun-timepluserrorplus-plustheplusconnect = txtPassword.Text Then If rs![user_type] = "Principal" Then MsgBox "The Principal has login", vbOKOnly + vbInformation, "LOGIN" frmMain.Transaction.Visible = 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_ http://www.dreamincode.net/forums/topic/289490-run-time-error-3709/ 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 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 Public con As New ADODB.Connection Public Sub OpenCon() Set con = New ADODB.Connection con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\database\enrollment.mdb" End Sub Was This Post Helpful? 0 Back to top MultiQuote Quote + Reply #4 maj3091 D.I.C Lover Reputation: 327 Posts: 1,944 Joined: 26-March 09 Re: run time error 3709 Posted 26 August 2012 - 02:10 AM Try checking if the connection is actually opened (think it's the State property). Was This Post Helpful? 0 Back to top MultiQuote Quote + Reply #5 BobRo
? Ask a question, help others, and get answers from the community Discussions Start a thread and discuss today's topics with top experts Blogs Read the latest tech blogs written http://itknowledgeexchange.techtarget.com/itanswers/how-to-fix-run-time-error-3709-with-my-computer/ by experienced community members How to fix run-time error 3709 with my https://www.daniweb.com/programming/software-development/threads/291765/vb6-run-time-error-3709 computer beginner1 5 pts. Tags: Thanks! We'll email youwhen relevant content isadded and updated. Following Follow Visual Basic 6 Thanks! We'll email youwhen relevant content isadded and updated. Following Follow Visual Basic Error Messages When I try to run my program it says run-time error 3709 the connection cannot error 3709 be used to perform this action, it is either closed or invalid in this context. mean while I used a module in which i put the following codes : Public cn As ADODB.Connection Public Sub Main() Dim cn As ADODB.Connection Set cn = New ADODB.Connection cn.ConnectionString = "C:UsersLab2c28DocumentsAuthors databaseauthors.mdb" cn.Open Form1.Show End Sub and then I put the following codes in a error 3709 visual save button : Private Sub cmdsave_Click() Dim rsauthors As New ADODB.Recordset Set rsauthors = New ADODB.Recordset With rsauthors: ActiveConnection = cn Source = ("SElect * From authors") . LockType = adLockOptimistic Open End With With rsauthors: AddNew Fields("Book ID_") = Text1.Text Fields("Name") = Text2.Text Update End With End Sub Please help meSoftware/Hardware used: VB6 Asked: October 11, 20122:08 PM Last updated: October 24, 201312:21 PM Related Questions Error in Select Statement How to connect Access database to a Visual Studio 2005? Runtime error: server has not yet been opened Crystal reports Runtime error: server has not yet been opened Crystal reports Error when tried to update the SSOledbGrid connected to with Sybase Server Database Answer Wiki Last updated: October 24, 201312:21 PM GMT Ametuer30 pts. History Contributors Ordered by most recent Ametuer30 pts. Michael Tidmarsh48,715 pts. beginner15 pts. Thanks. We'll let you know when a new response is added. You could use something like i have done below.Public adoDatabase As New ADODB.ConnectionDim rst As ADODB.Recordset Private Sub Form_Load()Set rst = New ADODB.Recordsetrst.Open "Reprocess", adoDatabase, adOpenKeyset, adLockOptimistic, adCmdTabletxtMName.Text = rst("ManufacturerName").ValuetxtMSno.Text = rst("MFR_SL_NO").ValuecboVirology.Text = rst("volume").V
3709 3Contributors 6Replies 10Views 6 YearsDiscussion Span 6 Years Ago Last Post by shena 0 6 Years Ago Respedted Seniors, I have a form to input a product model detail. When i run the project and choose to click the menu 'Model Master', an error as below occurred. Run-time error '3709': The connection cannot be used to perform this operation. it is either closed or invalid in this context. When i click debug, it highlighted the line as i have indicated below in the code: ------------------ frmMdelMaster.frm ------------------ Public search As Boolean Private Sub cmdMMDelete_Click() Dim bDMMaster As Boolean bDMMaster = False For i = 1 To Me.LVMMaster.ListItems.Count If Me.LVMMaster.ListItems(i).Checked = True Then Me.DELETE_MODEL_MASTER (Me.LVMMaster.ListItems(i).ListSubItems(1)) bDMMaster = True End If Next If bDMMaster = True Then MsgBox "Record Deleted", vbInformation Else MsgBox "No Record Deleted, To delete Check the boxes", vbCritical End If Call GET_LV_MODEL_MASTER End Sub Private Sub cmdSave_Click() 'Call ConnectDB If Len(Me.txtModel.Text) = 0 Then MsgBox "Empty Model", vbCritical Exit Sub End If If RECORD_EXIST(Me.txtModel.Text) = True Then DB.Execute "update MODEL_MASTER set BOXID='" & Me.txtBoxID.Text & "'," & _ "MODEL_DESCRIPTION='" & Me.txtDescription.Text & "' where MODEL_NAME='" & Me.txtModel.Text & "'" Else DB.Execute "insert into MODEL_MASTER(MODEL_NAME,BOXID,MODEL_DESCRIPTION) VALUES('" & Me.txtModel.Text & _ "','" & Me.txtBoxID.Text & "','" & Me.txtDescription.Text & "')" MsgBox "Record Saved!", vbInformation End If Call GET_LV_MODEL_MASTER End Sub Private Sub cmdSearch_Click() search = True Me.GET_LV_MODEL_MASTER End Sub Private Sub Form_Load() 'bModelMaster = False Call GET_LV_MODEL_MASTER End Sub Private Sub LVMMaster_Click() On Error Resume Next Dim rs As New ADODB.Recordset Dim sql As String sql = "SELECT * FROM MODEL_MASTER where MODEL_NAME ='" & Me.LVMMaster.SelectedItem.ListSubItems(1).Text & "'" rs.Open sql, DB, adOpenStatic, adLockReadOnly With rs Do While Not .EOF Me.txtBoxID.Text = Me.LVMMaster.SelectedItem.ListSubItems(2).Text Me.txtModel.Text = Me.LVMMaster.SelectedItem.ListSubItems(1).Text Me.txtDescription.Text = Me.LVMMaster.SelectedItem.ListSubItems(3).Text .MoveNext Loop End With End Sub Private Sub txtModel_L