Anzeige
Archiv - Navigation
668to672
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
668to672
668to672
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

ADODB + Select

ADODB + Select
16.09.2005 08:59:28
Gerald
hi, ich hab jetzt mal absichtlich einen fehler eingebaut
der DC_KEY ist in der datenbank nicht vorhanden!
wieso kommt dann bei recordset.Close:
Run-tim error '3219'
Operation is not allowed in this context
was soll ich in diesem fall machen, und wie prüfe ich ob der fehler von select kommt? anscheinend ist recordset gar nicht opened?
cu
For rowcount = 1 To rows - 1
command.CommandText = "Select * From Fehlerk.Defectcatalog Where DC_KEY=" + Cells(rowstart + rowcount, colstart + keycolumn - 1).Text
recordset.CursorLocation = adUseClient
recordset.Open command, , adOpenStatic, adLockOptimistic
On Error GoTo ErrorHandler
recordset.MoveFirst
.....
.....
.....
ErrorHandler:
For Each errorObject In recordset.ActiveConnection.Errors
MsgBox "Description: " + errorObject.Description
MsgBox "Number: " + Hex(errorObject.Number)
Next
recordset.Close
Next rowcount

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: ADODB + Select
16.09.2005 09:45:32
Gerald
hab was gefunden:
Modifying Existing Records
With rsSalesStaff
.MoveFirst
.Find “StaffId = ‘ ” & txtStaffId.Text & “ ’ ”
If Not .EOF Then
!FirstName = txtFirstName.Text
!LastName = txtLastName.Text
!HireDate = txtHireDate.Text
!IsFullTime = (chkFullTime.Value = vbChecked)
!Salary = Val(txtSalary.Text)
.Update
Else
MsgBox “Cannot locate Staff ID “ & txtStaffId.Text
End If
End With
Note: You can only close a Recordset whose EditMode is adEditNone. If its EditMode is adEditInProgress or adEditAdd and you try to close the Recordset, runtime error 3219 occurs.
Checking EditMode Before Closing a Recordset

Private Sub Form_Unload(Cancel As Integer)
If CloseRecordset(mrsSalesStaff) Then
CnSalesStaff.Close
Else
MsgBox “You must cancel the current Add or Edit “ _
& “operation first.”, vbInformation, “”
Cancel = True
End If
End Sub

Public Function CloseRecordset(rsAny As ADODB.Recordset) _
As Boolean
If rsAny.EditMode = adEditNone Then
RsAny.Close
CloseRecordset = True
Else
CloseRecordset = False
End If
End Function
Note: The cursor must be pointing to a valid record before the EditMode property’s setting is checked, to avoid runtime error 3021.
ABER WOHIN NUN?
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige