Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_components thread: Help a newbie...


Message #1 by giswim1@a... on Wed, 8 Aug 2001 20:03:57
I have built a dll with a class that will execute a stored procedure to 

insert a row into the database.  I then have an asp page that accesses 

this class.  However I am getting a type mismatch error when I try to run 

the page.  It says the error is on the line where the class is called.  My 

code for both the asp and the dll are below.  I appreciate any help you 

can give!



<<<DLL>>>









Public Function AddIssue( _

                        strSubmittedBy As String, _

                        strResolution As String, _

                        strSummary As String, _

                        strDateSubmitted As String, _

                        strStatus As String, _

                        strPriority As String, _

                        strAssignedTo As String, _

                        strPlannedCompDate As String, _

                        strAppName As String, _

                        strDateCompleted As String, _

                        strCompletedBy As String _

                        ) As Integer



On Error GoTo EH_AddIssue



Dim objRS As ADODB.Recordset

Dim objConn As ADODB.Connection

Dim strSubject, strMailTo, strBody As String





strSummary = Replace(strSummary, "'", "`")

strResolution = Replace(strResolution, "'", "`")



'Open connection to database

objConn.Open ConnectionString



'Open Recordset and insert values

objRS.Open "spAddIssue '" & strSubmittedBy & "', '" & strResolution 

& " ', '" & _

        strSummary & "', '" & strDateSubmitted & "', '" & _

        strStatus & "', '" & strPriority & "', '" & strAssignedTo & "', '" 

& _

        strPlannedCompDate & "', '" & strAppName & "', '" & 

strDateCompleted & "', '" & _

        strCompletedBy & "'", objConn



'Return Issue ID

AddIssue = objRS.Fields(0)



'Set subject for e-mail report

strSubject = "New " & strAppName & " Issue #" & objRS.Fields(0)



'Close recordset and connection and release memory

objRS.Close

Set objRS = Nothing

objConn.Close

Set objConn = Nothing



'Set up e-mail report body

strBody = "A new issue has been submitted for " & strAppName & ":" & 

vbCrLf & _

        "Submitted by: " & strSubmittedBy & " on " & strDateSubmitted & 

vbCrLf & _

        "Summary: " & strSummary & vbCrLf & "Status: " & strStatus & 

vbCrLf & _

        "Priority: " & strPriority & vbCrLf & vbCrLf & _

        "Assigned to: " & strAssignedTo & vbCrLf & "Planned completion 

date: " & _

        strPlannedCompDate & vbCrLf & vbCrLf & "Resolution: " & 

strResolution & vbCrLf & _

        "Completed on: " & strDateCompleted & " by " & strCompletedBy





EH_AddIssue:

    DumpErrors objConn

    WriteToLog "Issues:AddIssue" & vbCrLf & sMsg & vbCrLf & Err.Description

    Resume Next

    

End Function



<<<ASP>>>

<%@ Language=VBScript %>

<%Response.Buffer = true%>

<%

dim objIssue 'as Issues.clsIssueTrack

dim strSumittedBy, strSummary, strResolution, strDateSubmitted, strStatus, 

strPriority, strAssignedTo, _

	strPlannedCompDate, strAppName, strDateCompleted, 

strCompletedBy 'as Strings

dim intID as int



strSubmittedBy = Request.Form("name")

strSummary = Request.Form("summary")

strResolution = Request.Form("resolution")

strDateSubmitted = Now()

strStatus = Request.Form("status")

strPriority = Request.Form("priority")

strAssignedTo = Request.Form("assignedto")

strPlannedCompDate = Request.Form("plannedcompdate")

strAppName = "Broker Vote"

strDateCompleted = Request.Form("datecompleted")

strCompletedBy = Request.Form("completedby")



set objIssue = server.CreateObject ("Issues.clsIssueTrack")

intID = objIssue.AddIssue(strSubmittedBy, strResolution, strSummary, 

strDateSubmitted, strStatus, _

						strPriority, 

strAssignedTo, strPlannedCompDate, strAppName, strDateCOmpleted, _

						strCompletedBy)

%>

<HTML>

<HEAD>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<link href="styles/styles.CSS" rel="stylesheet" type="text/css">

</HEAD>

<table width=100% border=1 cellspacing=0 cellpadding=0>

<tr>

	<td class=topright>Broker Vote Issue Tracking</tr>

<tr><td class=bottomleft valign=top>

	<font size=+1>Users</font><ul>

		<li>-Submit Issue >>>

		<li><a href="userview.asp">View Issue</a>

	</ul>

	<font size=+1>Developers</font><ul>

		<li><a href="devsub.asp">Submit Issue</a>

		<li><a href="devview.asp">View Issues</a>

	</ul>

</td>

<td class=bottomright valign=top>

Your issue has been submitted.  The corresponding issue ID is #<%=intID%>.

	

	

</BODY>

</HTML>

Message #2 by "Arbon Reimer" <arbon_reimer@h...> on Wed, 8 Aug 2001 13:54:51 -0600
You might try assigning all the arguments as Variant instead of String, and

see if that solves anything.  That has helped me before.



HTH

AR

----- Original Message -----

From: <giswim1@a...>

To: "ASP components" <asp_components@p...>

Sent: Wednesday, August 08, 2001 8:03 PM

Subject: [asp_components] Help a newbie...





> I have built a dll with a class that will execute a stored procedure to

> insert a row into the database.  I then have an asp page that accesses

> this class.  However I am getting a type mismatch error when I try to run

> the page.  It says the error is on the line where the class is called.  My

> code for both the asp and the dll are below.  I appreciate any help you

> can give!

>

> <<<DLL>>>

>

>

>

>

> Public Function AddIssue( _

>                         strSubmittedBy As String, _

>                         strResolution As String, _

>                         strSummary As String, _

>                         strDateSubmitted As String, _

>                         strStatus As String, _

>                         strPriority As String, _

>                         strAssignedTo As String, _

>                         strPlannedCompDate As String, _

>                         strAppName As String, _

>                         strDateCompleted As String, _

>                         strCompletedBy As String _

>                         ) As Integer

>

> On Error GoTo EH_AddIssue

>

> Dim objRS As ADODB.Recordset

> Dim objConn As ADODB.Connection

> Dim strSubject, strMailTo, strBody As String

>

>

> strSummary = Replace(strSummary, "'", "`")

> strResolution = Replace(strResolution, "'", "`")

>

> 'Open connection to database

> objConn.Open ConnectionString

>

> 'Open Recordset and insert values

> objRS.Open "spAddIssue '" & strSubmittedBy & "', '" & strResolution

> & " ', '" & _

>         strSummary & "', '" & strDateSubmitted & "', '" & _

>         strStatus & "', '" & strPriority & "', '" & strAssignedTo & "', '"

> & _

>         strPlannedCompDate & "', '" & strAppName & "', '" &

> strDateCompleted & "', '" & _

>         strCompletedBy & "'", objConn

>

> 'Return Issue ID

> AddIssue = objRS.Fields(0)

>

> 'Set subject for e-mail report

> strSubject = "New " & strAppName & " Issue #" & objRS.Fields(0)

>

> 'Close recordset and connection and release memory

> objRS.Close

> Set objRS = Nothing

> objConn.Close

> Set objConn = Nothing

>

> 'Set up e-mail report body

> strBody = "A new issue has been submitted for " & strAppName & ":" &

> vbCrLf & _

>         "Submitted by: " & strSubmittedBy & " on " & strDateSubmitted &

> vbCrLf & _

>         "Summary: " & strSummary & vbCrLf & "Status: " & strStatus &

> vbCrLf & _

>         "Priority: " & strPriority & vbCrLf & vbCrLf & _

>         "Assigned to: " & strAssignedTo & vbCrLf & "Planned completion

> date: " & _

>         strPlannedCompDate & vbCrLf & vbCrLf & "Resolution: " &

> strResolution & vbCrLf & _

>         "Completed on: " & strDateCompleted & " by " & strCompletedBy

>

>

> EH_AddIssue:

>     DumpErrors objConn

>     WriteToLog "Issues:AddIssue" & vbCrLf & sMsg & vbCrLf &

Err.Description

>     Resume Next

>

> End Function

>

> <<<ASP>>>

> <%@ Language=VBScript %>

> <%Response.Buffer = true%>

> <%

> dim objIssue 'as Issues.clsIssueTrack

> dim strSumittedBy, strSummary, strResolution, strDateSubmitted, strStatus,

> strPriority, strAssignedTo, _

> strPlannedCompDate, strAppName, strDateCompleted,

> strCompletedBy 'as Strings

> dim intID as int

>

> strSubmittedBy = Request.Form("name")

> strSummary = Request.Form("summary")

> strResolution = Request.Form("resolution")

> strDateSubmitted = Now()

> strStatus = Request.Form("status")

> strPriority = Request.Form("priority")

> strAssignedTo = Request.Form("assignedto")

> strPlannedCompDate = Request.Form("plannedcompdate")

> strAppName = "Broker Vote"

> strDateCompleted = Request.Form("datecompleted")

> strCompletedBy = Request.Form("completedby")

>

> set objIssue = server.CreateObject ("Issues.clsIssueTrack")

> intID = objIssue.AddIssue(strSubmittedBy, strResolution, strSummary,

> strDateSubmitted, strStatus, _

> strPriority,

> strAssignedTo, strPlannedCompDate, strAppName, strDateCOmpleted, _

> strCompletedBy)

> %>

> <HTML>

> <HEAD>

> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

> <link href="styles/styles.CSS" rel="stylesheet" type="text/css">

> </HEAD>

> <table width=100% border=1 cellspacing=0 cellpadding=0>

> <tr>

> <td class=topright>Broker Vote Issue Tracking</tr>

> <tr><td class=bottomleft valign=top>

> <font size=+1>Users</font><ul>

> <li>-Submit Issue >>>

> <li><a href="userview.asp">View Issue</a>

> </ul>

> <font size=+1>Developers</font><ul>

> <li><a href="devsub.asp">Submit Issue</a>

> <li><a href="devview.asp">View Issues</a>

> </ul>

> </td>

> <td class=bottomright valign=top>

> Your issue has been submitted.  The corresponding issue ID is #<%=intID%>.

>

>

> </BODY>

> </HTML>



Message #3 by geoff@v... on Thu, 9 Aug 2001 09:15:57 +0100
This is due to the code in your DLL to be strong typed, by this I mean that

you explicitly declare the type of variable that you are expecting for the

public method. As the method expects all the passed arguaments to be strings

then you can use CSTR(your variable) when passing the arguaments.

Or, you could change the method so as to expect variants as VBScript is NOT

strong typed and uses variants for all variables.



Should solve your problem



Geoff





> Subject: Help a newbie...

> From: giswim1@a...

> Date: Wed, 8 Aug 2001 20:03:57

> X-Message-Number: 2

>

> I have built a dll with a class that will execute a stored procedure to

> insert a row into the database.  I then have an asp page that accesses

> this class.  However I am getting a type mismatch error when I try to run

> the page.  It says the error is on the line where the class is called.  My

> code for both the asp and the dll are below.  I appreciate any help you

> can give!

>

> <<<DLL>>>

>

>

>

>

> Public Function AddIssue( _

>                         strSubmittedBy As String, _

>                         strResolution As String, _

>                         strSummary As String, _

>                         strDateSubmitted As String, _

>                         strStatus As String, _

>                         strPriority As String, _

>                         strAssignedTo As String, _

>                         strPlannedCompDate As String, _

>                         strAppName As String, _

>                         strDateCompleted As String, _

>                         strCompletedBy As String _

>                         ) As Integer

>

> On Error GoTo EH_AddIssue

>

> Dim objRS As ADODB.Recordset

> Dim objConn As ADODB.Connection

> Dim strSubject, strMailTo, strBody As String

>

>

> strSummary = Replace(strSummary, "'", "`")

> strResolution = Replace(strResolution, "'", "`")

>

> 'Open connection to database

> objConn.Open ConnectionString

>

> 'Open Recordset and insert values

> objRS.Open "spAddIssue '" & strSubmittedBy & "', '" & strResolution

> & " ', '" & _

>         strSummary & "', '" & strDateSubmitted & "', '" & _

>         strStatus & "', '" & strPriority & "', '" & strAssignedTo & "', '"

> & _

>         strPlannedCompDate & "', '" & strAppName & "', '" &

> strDateCompleted & "', '" & _

>         strCompletedBy & "'", objConn

>

> 'Return Issue ID

> AddIssue = objRS.Fields(0)

>

> 'Set subject for e-mail report

> strSubject = "New " & strAppName & " Issue #" & objRS.Fields(0)

>

> 'Close recordset and connection and release memory

> objRS.Close

> Set objRS = Nothing

> objConn.Close

> Set objConn = Nothing

>

> 'Set up e-mail report body

> strBody = "A new issue has been submitted for " & strAppName & ":" &

> vbCrLf & _

>         "Submitted by: " & strSubmittedBy & " on " & strDateSubmitted &

> vbCrLf & _

>         "Summary: " & strSummary & vbCrLf & "Status: " & strStatus &

> vbCrLf & _

>         "Priority: " & strPriority & vbCrLf & vbCrLf & _

>         "Assigned to: " & strAssignedTo & vbCrLf & "Planned completion

> date: " & _

>         strPlannedCompDate & vbCrLf & vbCrLf & "Resolution: " &

> strResolution & vbCrLf & _

>         "Completed on: " & strDateCompleted & " by " & strCompletedBy

>

>

> EH_AddIssue:

>     DumpErrors objConn

>     WriteToLog "Issues:AddIssue" & vbCrLf & sMsg & vbCrLf &

Err.Description

>     Resume Next

>

> End Function

>

> <<<ASP>>>

> <%@ Language=VBScript %>

> <%Response.Buffer = true%>

> <%

> dim objIssue 'as Issues.clsIssueTrack

> dim strSumittedBy, strSummary, strResolution, strDateSubmitted, strStatus,

> strPriority, strAssignedTo, _

> strPlannedCompDate, strAppName, strDateCompleted,

> strCompletedBy 'as Strings

> dim intID as int

>

> strSubmittedBy = Request.Form("name")

> strSummary = Request.Form("summary")

> strResolution = Request.Form("resolution")

> strDateSubmitted = Now()

> strStatus = Request.Form("status")

> strPriority = Request.Form("priority")

> strAssignedTo = Request.Form("assignedto")

> strPlannedCompDate = Request.Form("plannedcompdate")

> strAppName = "Broker Vote"

> strDateCompleted = Request.Form("datecompleted")

> strCompletedBy = Request.Form("completedby")

>

> set objIssue = server.CreateObject ("Issues.clsIssueTrack")

> intID = objIssue.AddIssue(strSubmittedBy, strResolution, strSummary,

> strDateSubmitted, strStatus, _

> strPriority,

> strAssignedTo, strPlannedCompDate, strAppName, strDateCOmpleted, _

> strCompletedBy)

> %>

> <HTML>

> <HEAD>

> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

> <link href="styles/styles.CSS" rel="stylesheet" type="text/css">

> </HEAD>

> <table width=100% border=1 cellspacing=0 cellpadding=0>

> <tr>

> <td class=topright>Broker Vote Issue Tracking</tr>

> <tr><td class=bottomleft valign=top>

> <font size=+1>Users</font><ul>

> <li>-Submit Issue >>>

> <li><a href="userview.asp">View Issue</a>

> </ul>

> <font size=+1>Developers</font><ul>

> <li><a href="devsub.asp">Submit Issue</a>

> <li><a href="devview.asp">View Issues</a>

> </ul>

> </td>

> <td class=bottomright valign=top>

> Your issue has been submitted.  The corresponding issue ID is #<%=intID%>.

>

>

> </BODY>

> </HTML>







Message #4 by giswim1@a... on Thu, 9 Aug 2001 00:17:57
Actually I realized that after I had posted this question... an it 

worked :)  Thanks



> You might try assigning all the arguments as Variant instead of String, 

and

> see if that solves anything.  That has helped me before.

> 

> HTH

> AR

>
Message #5 by "Gerhard Wentink" <data@w...> on Thu, 9 Aug 2001 07:50:59 +0200
Yes that would sove the problem but it also consumes a lot af memory.

Better: assign the arguments ByVal:

Public Function AddIssue( _

                            ByVal strSubmittedBy As String, _     etc. etc.



Regards,

Gerhard Wentink



----- Original Message -----

From: "Arbon Reimer" <arbon_reimer@h...>

To: "ASP components" <asp_components@p...>

Sent: Wednesday, August 08, 2001 9:54 PM

Subject: [asp_components] Re: Help a newbie...





> You might try assigning all the arguments as Variant instead of String,

and

> see if that solves anything.  That has helped me before.

>

> HTH

> AR

>
Message #6 by giswim1@a... on Fri, 10 Aug 2001 03:54:07
I tried that, but it didn't work... I got the types error again...  kinda 

weird... a co-worker has written a dll and two pages (one for production 

and one to test the dll).  they are essentially the same, but for some 

reason the test asp page works with the dll but the prod one doesn't... 

kinda weird, but not relating to my question... anyway, I haven't tried 

the cstr approach yet, and I will do that tomorrow when I get in the 

office.  But I did try the ByVal approach and still got the same error.  

in the sproc the parameters are taken in as varchar and inserted into the 

table as text.  would this have anything to do with it?  should I change 

the table (still early enough in dev to do this) to have varchar's instead 

of text columns?  i did fine with straight asp and an access (don't 

laugh :)) database, but as I said before, I'm new to both writing dll's 

and to sybase databases, so any help would be great.



thanks!



Grant



> Yes that would sove the problem but it also consumes a lot af memory.

> Better: assign the arguments ByVal:

> Public Function AddIssue( _

>                             ByVal strSubmittedBy As String, _     etc. 

etc.
Message #7 by "Gerhard Wentink" <data@w...> on Sat, 11 Aug 2001 07:31:53 +0200
I think you have to check the value of the variable the function returns.

Are you sure that the stored procedure passes the objRs.Fields(0) Value?

Perhaps you should use a Command object to pass in the parameters and get

back the output paramater. Its a bit more coding, but it gives you more

control.

I think its always better to use varchar in stead of text columns, because

text columns use a

lot more resources. You are limited to 255 characters however.

And why should I laugh if somebody uses access.



Regards,



Gerhard Wentink



----- Original Message -----

From: <giswim1@a...>

To: "ASP components" <asp_components@p...>

Sent: Friday, August 10, 2001 3:54 AM

Subject: [asp_components] Re: Help a newbie...





> I tried that, but it didn't work... I got the types error again...  kinda

> weird... a co-worker has written a dll and two pages (one for production

> and one to test the dll).  they are essentially the same, but for some

> reason the test asp page works with the dll but the prod one doesn't...

> kinda weird, but not relating to my question... anyway, I haven't tried

> the cstr approach yet, and I will do that tomorrow when I get in the

> office.  But I did try the ByVal approach and still got the same error.

> in the sproc the parameters are taken in as varchar and inserted into the

> table as text.  would this have anything to do with it?  should I change

> the table (still early enough in dev to do this) to have varchar's instead

> of text columns?  i did fine with straight asp and an access (don't

> laugh :)) database, but as I said before, I'm new to both writing dll's

> and to sybase databases, so any help would be great.

>

> thanks!

>

> Grant

>

> > Yes that would sove the problem but it also consumes a lot af memory.

> > Better: assign the arguments ByVal:

> > Public Function AddIssue( _

> >                             ByVal strSubmittedBy As String, _     etc.

> etc.

>


  Return to Index