-
F8
hi
i want to connect to oracle database but it give me error massege
"object required"
and itsn't insert data in to table :(
and whin i check by clecking on"F8" it will exexute with out insert :(
could you please check this code for me
Code:
Private Sub ConnectToServer1(y As String)
procedure:
Dim StrSQL As String
On Error GoTo ErrMsg
Set rsMCare = New ADODB.Recordset
Set rsMCare.ActiveConnection = cnMCare
y = y & " , " & Format(Now, "HH:MM:SS")
'y = y
' insert the value in the StuId table
StrSQL = "insert into STUID VALUES("" & y & "");"
rsMCare.Source = StrSQL
rsMCare.Open
If rsMCare.State = 1 Then rsMCare.Close
Exit Sub
ErrMsg:
MsgBox "Error: " & Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
InRFIDCtrl1.Close
End Sub
Public Function ConnectToServer() As Boolean
'On Error Goto ErrMsg
Set cnMCare = New ADODB.Connection
' here is the name,user and the password of the database
cnMCare.Open "Provider=MSDAORA;DSN=coe485;uid=yosef;pwd=coe485"
If cnMCare = adStateOpen Then
MsgBox "Welcome to Pubs!"
Else
MsgBox "Sorry. No Pubs today."
End If
'cnMCare.Open "Provider=MSDASQL;DSN=;uid=user;pwd=password"
Set rsMCare = New ADODB.Recordset
cnMCare.CursorLocation = adUseClient
rsMCare.CursorType = adOpenStatic 'use for reports only
rsMCare.CursorLocation = adUseClient
rsMCare.LockType = adLockPessimistic
Set rsMCare.ActiveConnection = cnMCare
ConnectToServer = True
Exit Function
ErrMsg:
MsgBox Err.Description
ConnectToServer = False
Exit Function
End Function
Public Status As Integer
Public cnMCare As ADODB.Connection
Public rsMCare As ADODB.Recordset
Public rsMCare1 As ADODB.Recordset
Public rsMCare2 As ADODB.Recordset
-
Re: F8
Code:
could you please check this code for me
Yeah we Can.
But unfortunately you have used the [INVISIBLE] tags, so we cant see the code.
Please post the code with [CODE] tags.
Thanks
:wave:
-
Re: F8
thank you for your response
Private Sub ConnectToServer1(y As String)
procedure:
Dim StrSQL As String
On Error GoTo ErrMsg
Set rsMCare = New ADODB.Recordset
Set rsMCare.ActiveConnection = cnMCare
y = y & " , " & Format(Now, "HH:MM:SS")
'y = y
' insert the value in the StuId table
StrSQL = "insert into STUID VALUES("" & y & "");"
rsMCare.Source = StrSQL
rsMCare.Open
If rsMCare.State = 1 Then rsMCare.Close
Exit Sub
ErrMsg:
MsgBox "Error: " & Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
InRFIDCtrl1.Close
End Sub
Public Function ConnectToServer() As Boolean
'On Error Goto ErrMsg
Set cnMCare = New ADODB.Connection
' here is the name,user and the password of the database
cnMCare.Open "Provider=MSDAORA;DSN=coe485;uid=yosef;pwd=coe485"
If cnMCare = adStateOpen Then
MsgBox "Welcome to Pubs!"
Else
MsgBox "Sorry. No Pubs today."
End If
'cnMCare.Open "Provider=MSDASQL;DSN=;uid=user;pwd=password"
Set rsMCare = New ADODB.Recordset
cnMCare.CursorLocation = adUseClient
rsMCare.CursorType = adOpenStatic 'use for reports only
rsMCare.CursorLocation = adUseClient
rsMCare.LockType = adLockPessimistic
Set rsMCare.ActiveConnection = cnMCare
ConnectToServer = True
Exit Function
ErrMsg:
MsgBox Err.Description
ConnectToServer = False
Exit Function
End Function
Public Status As Integer
Public cnMCare As ADODB.Connection
Public rsMCare As ADODB.Recordset
Public rsMCare1 As ADODB.Recordset
Public rsMCare2 As ADODB.Recordset
(Rate)
-
Re: F8
Thread moved to Database Development forum
As you haven't mentioned which line the error occurs on, there isn't much we can do about that. (you can find generic advice on this error in the "fixing common VB errors" link in my signature).
Note that the way you build StrSQL is not apt (it will contain the text (" & y & ") , not the value of your variable y). See the SQL section of our Database Development FAQs/Tutorials (at the top of this forum)
There is also no need to use a Recordset to run it (it is a waste of CPU time, memory, and network usage), see the "How do I add a record" article in the ADO section of the FAQs, which shows how to use the Connection instead.
-
Re: F8
-
Re: F8
To be able to help you any more than we have, you need to give us more information.
If you want help with the error, tell us where it occurs.
If you want help with something else, give us an explanation of what.