Help Help Please ! Runtime Error 3001 in vb6 and oracle 8i [message #126277] |
Sat, 02 July 2005 15:01 |
ilike3000
Messages: 2 Registered: July 2005
|
Junior Member |
|
|
I've some problems with my vb6 and oracle, it keep showing "runtime error 3001". below is my code can anyone here pls help me to solve it.. thanks
== This is my connection function ==
Private IsConnect As Boolean
Private Connect_Num As Integer
Private cnn As ADODB.Connection
Private rs As ADODB.Recordset
Private Sub Connect()
If IsConnect = True Then
Exit Sub
End If
Set cnn = New ADODB.Connection
cnn.ConnectionString = "DSN=" + DSN + ";UID=" + DB_USER_NAME _
+ ";PWD=" + DB_PASSWORD + ";"
cnn.Open
If cnn.State <> adStateOpen Then
MsgBox "Database Connection Failed"
End
End If
IsConnect = True
End Sub
Private Sub Disconnect()
Dim Rc As Long
If IsConnect = False Then
Exit Sub
End If
cnn.Close
Set cnn = Nothing
IsConnect = False
End Sub
Public Sub DB_Connect()
Connect_Num = Connect_Num + 1
Connect
End Sub
Public Sub DB_Disconnect()
If Connect_Num >= CONNECT_LOOP_MAX Then
Connect_Num = 0
Disconnect
End If
End Sub
Public Sub DBapi_Disconnect()
Connect_Num = 0
Disconnect
End Sub
Public Sub SQLExt(ByVal TmpSQLstmt As String)
Dim cmd As New ADODB.Command
DB_Connect
Set cmd.ActiveConnection = cnn
cmd.CommandText = TmpSQLstmt
cmd.Execute
Set cmd = Nothing
DB_Disconnect
End Sub
Public Function QueryExt(ByVal TmpSQLstmt As String) As ADODB.Recordset
Dim rst As New ADODB.Recordset
DB_Connect
Set rst.ActiveConnection = cnn
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open TmpSQLstmt
Set QueryExt = rst
End Function
|
|
|
Re: Help Help Please ! Runtime Error 3001 in vb6 and oracle 8i [message #126278 is a reply to message #126277] |
Sat, 02 July 2005 15:04 |
ilike3000
Messages: 2 Registered: July 2005
|
Junior Member |
|
|
== This is my function ==
Dim rstRegion As New ADODB.Recordset
Dim lssql As String
Private Sub cmdCancel_Click()
Call clearField
End Sub
Private Sub cmdDelete_Click()
Call DeleteRecord
Call clearField
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
On Error GoTo err_handler
Call SaveRecord
Call clearField
err_handler:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub SaveRecord()
lssql = "Select * from Region where ID = '" & Trim(txtID.Text) & "'"
Set rstRegion = Nothing
rstRegion.Open lssql, cnn, adOpenDynamic, adLockOptimistic
With rstRegion
If .EOF And .BOF Then
.AddNew
!ID = IIf(IsNull(txtID), "", txtID)
End If
!Description = IIf(IsNull(txtDescription), "", txtDescription)
.Update
End With
End Sub
Private Sub LoadRecord()
lssql = "Select * from Region where ID = '" & Trim(txtID.Text) & "'"
Set rstRegion = Nothing
rstRegion.Open lssql, cnn, adOpenDynamic, adLockOptimistic
With rstRegion
If Not .EOF And Not .BOF Then
txtID = !ID
txtDescription = !Description
End If
End With
End Sub
Private Sub DeleteRecord()
lssql = "Delete from Region where ID = '" & Trim(txtID) & "'"
Set rstRegion = Nothing
rstRegion.Open "Select * from Region", cnn, adOpenDynamic, adLockOptimistic
rstRegion.ActiveConnection.Execute lssql
End Sub
Private Sub clearField()
txtID = ""
txtDescription = ""
txtID.SetFocus
End Sub
Private Sub txtDescription_GotFocus()
SendKeys "{Home}+{End}"
End Sub
Private Sub txtDescription_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub txtID_GotFocus()
SendKeys "{Home}+{End}"
End Sub
Private Sub txtID_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub txtID_LostFocus()
Call LoadRecord
End Sub
|
|
|