|
-
Jun 5th, 2000, 04:11 PM
#1
Thread Starter
Addicted Member
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
-
Jun 5th, 2000, 05:03 PM
#2
New Member
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).
-
Jun 5th, 2000, 05:52 PM
#3
Frenzied Member
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
-
Jun 5th, 2000, 07:05 PM
#4
Thread Starter
Addicted Member
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
-
Jun 5th, 2000, 07:23 PM
#5
Fanatic Member
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!
-
Jun 5th, 2000, 07:27 PM
#6
Thread Starter
Addicted Member
Humble Apologies to Mark, and Ian. This suggestion worked completely.
Many thanks for the help.
Lenin.
-
Jun 5th, 2000, 07:34 PM
#7
Frenzied Member
That's OK! No hard feelings! 
-
Jun 5th, 2000, 07:38 PM
#8
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|