|
-
May 7th, 2001, 02:14 PM
#1
Thread Starter
Lively Member
VB Experts..need help..!!!!
I'm compiling this code as a dll to run in MTS..I've created a simple ASP page to run a simple update or save method..not sure if my code is correct but I receive a type mistmatch error.
here's how it looks in ASP
<%@ Language=VBScript %>
<%
Set obj=Server.CreateObject("CorpHighYield.company")
obj.UpdateCompany "Revlon", "REVLN", "11"
%>
Error message I receive:
Public Function UpdateCompany(CompanyName As Long, BondTicker As Long, IndustryID As Integer, Optional CompanyID As Integer)
Dim rsCompany As ADODB.Connection, sSQL As String, objDB As Object, stat As Long
On Error GoTo ErrorHandler
'** Create instance of the database engine object
Set objDB = GetObjectContext.CreateInstance("MTSBaDbEngine.Engine")
If Not IsMissing(CompanyID) Then
'** Build query to update Company Name
sSQL = "update HighYieldCompany set CompanyName= " & CompanyName
sSQL = sSQL & "where companyID=" & CompanyID
ElseIf Not IsMissing(CompanyID) Then
'** Build query to update BondTicker
sSQL = "update HighYieldCompany set BondTicker= " & BondTicker
sSQL = sSQL & "where companyID=" & CompanyID
Else
If Not IsMissing(CompanyID) Then
sSQL = "insert into HighYieldCompany(CompanyName, BondTicker, FK_IndustryID) values(" & _
CompanyName & ", '" & BondTicker & "','" & IndustryID & "')"
If Not stat = 0 Then
'** Build query to insert new record
sSQL = "insert into HighYieldCompany(CompanyName, BondTicker, FK_IndustryID) values(" & _
CompanyName & ", '" & BondTicker & "','" & IndustryID & "')"
End If
stat = objDB.Execquery(sSQL)
End If
End If
'** Execute query
Call objDB.Execquery(sSQL)
'** Create recordset and pass back to client
Set UpdateCompany = rsCompany
Set objDB = Nothing
GetObjectContext.SetComplete
Exit Function
ErrorHandler:
GetObjectContext.SetAbort
Err.Raise Number:=Err.Number, Description:=Err.Description, _
Source:=LIBRARY_NAME & "::" & CLASS_NAME & ".UpdateCompany()"
-
May 7th, 2001, 02:19 PM
#2
umm..duh 
Just kidding, you may have overlooked it. Happens to me alot
but you are passing strings into Long's
Look at your function declaration and how you are calling it
CompanyName As Long but you used that parameter as a string "Revelon"
-
May 7th, 2001, 02:24 PM
#3
Thread Starter
Lively Member
Should I just remove the quotes from revlon? and that should do it?
-
May 7th, 2001, 02:28 PM
#4
change the DEclaration in the function to Strings instead. And remove the qoutes around the 11.
Public Function UpdateCompany(CompanyName As String, BondTicker As String, IndustryID As Integer, Optional CompanyID As Integer)
Set obj=Server.CreateObject("CorpHighYield.company")
obj.UpdateCompany "Revlon", "REVLN", 11
That should do it for ya.
-
May 7th, 2001, 02:38 PM
#5
Thread Starter
Lively Member
Almost there ..got a little further than before...got an
error..but a different one..How is does my if ..then else statement looks?
error '8004e002'
/test/hy.asp, line 5
-
May 7th, 2001, 02:46 PM
#6
problem is, that error could be anywhere in that function. Do this , declare a public variable called mstrErrMsg and on called mstrErrLabel.
Now in your function every couple of lines do this
mstrErrLabel = "section 1"
just change the number
then use the follwoing error hander
Code:
ErrHandler:
mstrErrMsg = mstrErrLabel & "ErrNo: " & str(Err.Number) & "Source: " & Err.Source _
& " Description: " & Err.Description
Err.Raise vbObjectError + 9, , mstrErrMsg
now when it errors , you will see the error message and the string saying section 1 or whatever number you used. Now you can find out more easily which line the problem is on. Try that out. Oh and dont forget to put your on error at the beggining of the function
On Error Goto ErrHandler
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
|