Results 1 to 6 of 6

Thread: F8

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2008
    Posts
    27

    Question 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

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    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

    IIF(Post.Rate > 0 , , )

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2008
    Posts
    27

    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)

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2008
    Posts
    27

    Re: F8

    i need more help

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width