Results 1 to 8 of 8

Thread: Problem with VB class connection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Hi,
    I am trying to create a VB class component to connect to SQL Server. The class uses a defined connection_string property which expects a string ( a DSN ), and makes a database connection as a result. However when I create the object in VBScript and try to set the connection_string property it fails with:

    Error Type:
    Microsoft VBScript runtime (0x800A01C2)
    Wrong number of arguments or invalid property assignment: 'connection_string'
    /tony/query_detail.asp, line 16


    VB Code:


    ------------------------------------------------------------

    Public Sub Make_Connection()
    Dim conn As ADODB.Connection

    Set conn = New ADODB.Connection
    '
    ' Implement the DSN
    '
    conn.Open Connection_String
    End Sub

    ------------------------------------------------------------

    Public Property Let Connection_String(ByVal vData As String)
    'used when assigning a value to the property, on the left side of an assignment.
    'Syntax: X.Connection_String = 5
    mvarConnection_String = vData
    End Property

    ------------------------------------------------------------

    Public Property Get Connection_String() As String
    'used when retrieving value of a property, on the right side of an assignment.
    'Syntax: Debug.Print X.Connection_String
    Connection_String = mvarConnection_String
    End Property

    ------------------------------------------------------------



    ASP Code:

    ------------------------------------------------------------

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    </head>

    <form action = "query_detail.asp" method = "post"></form>
    <body>
    <%
    dim detail_object
    dim ls_Detail_String

    set detail = server.createobject("Get_Detail.details")

    detail.connection_string "DSN=class" <--- Fails Here
    detail.make_connection
    ls_Detail_string = detail.get_details(16112, 3)


    response.write ls_detail

    %>


    </form>

    </body>
    </html>

    ------------------------------------------------------------


    Thanks in advance.

    Lenin

  2. #2
    New Member
    Join Date
    May 2000
    Posts
    12
    In your vb script you reference Get_Detail.details.
    Get_Detail should be the name of the DLL and details should be the name of the class yet when you try to reference this class you use the name detail instead of details.
    The easist way to avoid simple mistakes like this is to use the editor in interdev6. It will reconize the object and intellisense will show the exposed functions in the class. (
    I assume you did register the DLL).

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    No that's not right spower you can use whatever varaible name for the object that you want.

    I think you've got an = missing in the line:

    detail.connection_string "DSN=class" <--- Fails Here




    Mark
    -------------------

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    I think both of the submitions so far are incorrent.

    connection_string is a property of the class expecting a string, and therefore if I put an = into the failing line commands the environment with expect an object.
    connection_string is a property of the class object already created.


    Thanks for the input so far.

    Lenin

  5. #5
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Smile

    Hi lenin

    I'm in agreement with Mark on this. Where you say connection_string is a property, if you want to set a property to something you need the equals sign. It might be you are getting confused to procedures. If it were a procedure, then yes you wouldn't need the equals becuase you would be passing something to it.

    Try putting the equals in and it should work. I'm doing the same kind of thing as you are at the moment and it works just fine.

    Hope this Helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Humble Apologies to Mark, and Ian. This suggestion worked completely.

    Many thanks for the help.


    Lenin.

  7. #7
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    That's OK! No hard feelings!


    Mark
    -------------------

  8. #8
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    as the words of one of the members of this forum

    no ones perfect.


    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

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