Results 1 to 7 of 7

Thread: (RESOLVED) ADO - Whats wrong? pls have a look

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    (RESOLVED) ADO - Whats wrong? pls have a look

    Greetings,

    What is wrong with the following code?

    Every time run it I get in the line

    an error message (see below)
    Code:
    Option Explicit
    
    ' The database connection.
    Private m_Conn As ADODB.Connection
    
    Private Const CONNECT_STRING  As String = "Provider=OraOLEDB.Oracle.1;Password=XXXX;Persist Security Info=True;User ID=XXXX;Data Source=XXXX"
    
    Public Function GetStatusSTR(ByVal vName As String, ByVal vPW As String) As Integer
    Dim rs As ADODB.Recordset
    Dim strSQL As String
        strSQL = "SELECT S.USER_Status FROM ST_USER_STATUS S, ST_USER_ACCESS A WHERE "
        strSQL = strSQL & "A.STATUS = S.USER_STATUS_ID AND A.USERNAME = '" & vName
        strSQL = strSQL & "' AND A.PASSWORD = '" & vPW & "';"
        Set rs = m_Conn.Execute(strSQL)
        If rs.RecordCount > 0 Then
            GetStatusSTR = rs(0)
        Else
            GetStatusSTR = 0
        End If
        rs.Close
        Set rs = Nothing
        Exit Function
    End Function
    
    Private Sub Class_Initialize()
        ' Open the database connection.
        Set m_Conn = New ADODB.Connection
        m_Conn.ConnectionString = CONNECT_STRING
        m_Conn.Open
    End Sub
    
    Private Sub Class_Terminate()
        m_Conn.Close
        Set m_Conn = Nothing
    End Sub
    The error message is
    RunTime Error "-2147217900 (80040e14)
    ORA-00911:

    strSQL containes the following value when Set rs = m_Conn.Execute(strSQL) is executing
    "SELECT S.USER_Status FROM ST_USER_STATUS S, ST_USER_ACCESS A WHERE A.STATUS = S.USER_STATUS_ID AND A.USERNAME = 'zzz13204' AND A.PASSWORD = 'admin';"

    Many thanks in advance
    Last edited by Bongo; Jul 31st, 2002 at 08:22 AM.

  2. #2
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    try including the fields that you use in your WHERE clauses in the SELECT fieldname1, fieldname2 etc

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395
    ae_jester, nop did not work same error no

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395
    It was the semi colon on the end of the strSQL. After removing it worked

  5. #5
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    yeah that will do it :-)

  6. #6
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking 3:30pm...am tired...and hungry...need a garden fork!

    That wouldn't affect it at all...what line of code is it crashing on?
    Is it this one:
    VB Code:
    1. Set rs = m_Conn.Execute(strSQL)
    You could always try this code:
    VB Code:
    1. strSQL = "SELECT ST_User_Status.User_Status "
    2.     strSQL = strSQL & "FROM ST_User_Access "
    3.     strSQL = strSQL & "INNER JOIN ST_User_Status ON ST_User_Status.User_Status_ID = ST_User_Access.Status "
    4.     strSQL = strSQL & "WHERE ST_User_Access.Username = '" & vName & "' "
    5.     strSQL = strSQL & "AND ST_User_Access.Password = '" & vPW & "' "
    6.     Set rs = New Recordset
    7.     With rs
    8.         .CursorLocation = adUseClient
    9.         .Open strSQL, m_Conn, adOpenForwardOnly, adLockReadOnly
    10.         Set .ActiveConnection = Nothing
    11.         If .EOF Then
    12.             GetStatusSTR = 0
    13.         Else
    14.             GetStatusSTR = .Fields("User_Status").Value
    15.         End If
    16.     End With
    17.     Set rs = Nothing
    Hope this helps...

    Woka

  7. #7
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking Boooooooo...I am SLOW!

    Sorry, took ages to post that, I was refering to placing the search fields in the select statement
    Although the code above is alot clearer to understand

    Adios,

    Woka

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