Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_components thread: Re: Error Using MTS COM


Message #1 by "Chris Tucker" <chris.tucker@c...> on Fri, 9 Feb 2001 20:14:04
It appears that problem lies in your "GetMasterFiles" function on line 2:

  Set objMasters	= Server.CreateObject"CIT_LIB.Masters")



It should read:  Set objMasters	= Server.CreateObject("CIT_LIB.Masters")

Looks like you are missing the "(" around the ProgID.



Good luck.



> Hai,

>   I have created a COM which will registerd in MTS. In that dll, I have 3

> classes, 2 Classes to  update databases and 1 to get records from

> Masterfiles to fill drop downs. When every thing is fine there is no

> problem. But when an error occurs in com while updating ,say "truncation

> error in a character field" that error will be raised, but when i try to

> create object for Masterfile record fetching after the error, it shows the

> following error "error '8004e003' ".

> Both components are marked TRANSACTION REQUIRED.

> I am attaching code segments also.

> Please help me

> Sreekumar

> 

> ASP -> This will an Include file which handles the update

> ---

> If Request.Form("cmd_add_request") <> "" Then

>      GetValuesFromForm

>      'do validations if any

>      Dim m_strErrMsg

>      m_strErrMsg=ValidateFormData() 

>      ' Has error

>      If Len(m_strErrMsg) Then

> 	m_strMainPrompt=m_strMainPrompt& _

> 	" Following Fields are missing/in invalid format <br>" & _

>           m_strErrMsg

>      Else   

> 	If AddToTable = 1 Then ' database update occurred successfully

> 	   Response.Redirect("dsp_info_thanku.htm")

> 	   Response.End

> 	Else  ' database update did not occur successfully so let the user 

>               ' know

> 	    m_strMainPrompt = m_strMainPrompt & _		   

> 		  "A problem occurred while trying to update " & _

>                   " the database."  

> 	 End If

>      End If

>   End If

>   GetMasterFiles	 	

> 

> 

> 'updates database

>     Function AddToTable()

>         ' returns 1 on success, 0 on failure

> 	On Error Resume Next

> 	Dim obj

> 	Set obj = Server.CreateObject("CIT_LIB.RequestInformationForm")

> 	Call obj.AddToTable(m_strConnectionString,m_strFirstName, _

>                   m_strLastName,m_strTitle,m_strPhone, _

> 		  m_strEmail, m_strFax,m_strBusinessName , _

>                   m_strAddress1,m_strAddress2, _ 

> 		  m_strCity,m_strState_code ,m_strCountry_code , _

>  	          m_strZip ,m_strFederalTaxID,m_intIndustry_code, _

>    	          m_strIndustry_other ,m_intBusinessType_code, _

>                   m_strBusinessType_other , m_strYearsInBusiness, _

>                   m_strNumberOfEmployees ,m_strAnnualSales, _

>                   m_strNoOfActiveCustomers, m_strAverageInvoiceSize, _

>                   m_blnPresentlyFactored,m_strNameOfFactor, _ 

>                   m_blnPresentlyFinanced,m_strNameOfLender, _ 

>                   m_blnSecurityInterest, m_strNameOfSecuredParty, _ 

>                   m_strProducts_Services, m_intInfSource_code, _ 

>                   m_strInfSource_other,left(m_strComments,500))

> 	If Err.Number = 0 Then

> 	  AddToTable=1

> 	Else

> 	  ObjectContext.SetAbort

> 	  AddToTable=0

> 	End If

> 	Set Obj=Nothing

> 	Err.Clear

>     End Function

>     

>     Function GetMasterFiles()

>   	Dim objMasters

> 	Set objMasters	= Server.CreateObject"CIT_LIB.Masters")

> 	Set rsStates	= objMasters.GetMasterFile(m_strConnectionString,_

>                           STATES)

> 	Set rsCountry	= objMasters.GetMasterFile(m_strConnectionString, _

>                           COUNTRY)

> 	Set rsIndustry	= objMasters.GetMasterFile(m_strConnectionString, _

>                           INDUSTRY)				

> 	Set rsHowDidUHearAbout	=objMasters.GetMasterFile

>                                 (m_strConnectionString, HOWDIDUHEARABOUT)

> 	Set rsBusinessType = objMasters.GetMasterFile

>                                 (m_strConnectionString, BUSINESSTYPE)				

> 	Set rsPS = objMasters.GetMasterFile(m_strConnectionString, _

>                    PRODUCTS_SERVICES)						

> 	Set objMasters	=	Nothing

>     End Function

> End ASP -> 

> 

> COM ---->

> Public Function AddToTable(ByVal strConnectionString As String, _

>     ByVal m_strFirstName As String, ByVal m_strLastName As String, _

>     ByVal m_strTitle As String, ByVal m_strPhone As String, _

>     ByVal m_strEmail As String, ByVal m_strFax As String, _

>     ByVal m_strBusinessName As String, ByVal m_strAddress1 As String, _ 

>     ByVal m_strAddress2 As String, _

>     ByVal m_strCity As String, ByVal m_strState_code As String, _

>     ByVal m_strCountry_code As String, ByVal m_strZip As String, _ 

>     ByVal m_strFederalTaxID As String, ByVal m_intIndustry_code As Long, _

>     ByVal m_strIndustry_other As String, _ 

>     ByVal m_intBusinessType_code As Long, _ 

>     ByVal m_strBusinessType_other As String, _

>     ByVal m_strYearsInBusiness As String, _ 

>     ByVal m_strNumberOfEmployees As String, _ 

>     ByVal m_strAnnualSales As String, _

>     ByVal m_strNoOfActiveCustomers As String, _

>     ByVal m_strAverageInvoiceSize As String, _

>     ByVal m_blnPresentlyFactored  As Boolean, _ 

>     ByVal m_strNameOfFactor As String, _ 

>     ByVal m_blnPresentlyFinanced As Boolean, _

>     ByVal m_strNameOfLender As String, _ 

>     ByVal m_blnSecurityInterest As Boolean, _

>     ByVal m_strNameOfSecuredParty As String, _

>     ByVal m_strProducts_Services As String, _

>     ByVal m_intInfSource_code As Long, _

>     ByVal m_strInfSource_other As String, ByVal m_strComments As String)

>     

> 

>     On Error GoTo ErrorHandler

>     Dim objContext As ObjectContext

>     Set objContext = GetObjectContext

> 

>     Dim cn As ADODB.Connection, strSql As String

>     Dim mm_blnPresentlyFactored As Byte, mm_blnPresentlyFinanced As Byte,

> _

>     mm_blnSecurityInterest As Byte

>     mm_blnPresentlyFactored = IIf(m_blnPresentlyFactored, 1, 0)

>     mm_blnPresentlyFinanced = IIf(m_blnPresentlyFinanced, 1, 0)

>     mm_blnSecurityInterest = IIf(m_blnSecurityInterest, 1, 0)

> 

>     Set cn = CreateObject("ADODB.Connection")

> 

>     cn.Open strConnectionString

>     

>     

>     strSql = "INSERT INTO tblRequestInformationForm 

>     (strFirstName,strLastName,strTitle,strPhone, " & _

>   "strEmail, strFax,strBusinessName ,strAddress1,strAddress2," & _

>   " strCity,strState_code , strCountry_code , strZip ,strFederalTaxID," &

> _

>   " intIndustry_code, strIndustry_other

> ,intBusinessType_code,strBusinessType_other ," & _

>             " strYearsInBusiness,strNumberOfEmployees

> ,strAnnualSales,strNoOfActiveCustomers," & _

>             "

> strAverageInvoiceSize,blnPresentlyFactored,strNameOfFactor,blnPresentlyFinanced,"

> & _

>             "

> strNameOfLender,blnSecurityInterest,strNameOfSecuredParty,strProducts_Services,

> " & _

>             " intInfSource_code,strInfSource_other,strComments )"

> 

>     strSql = strSql & " VALUES ('"

>     strSql = strSql & SQLEncode(m_strFirstName) & "','" &

> SQLEncode(m_strLastName) & "','" & SQLEncode(m_strTitle) & "','" &

> SQLEncode(m_strPhone) & "','" & _

>              SQLEncode(m_strEmail) & "','" & SQLEncode(m_strFax) & "','" &

> SQLEncode(m_strBusinessName) & "','" & SQLEncode(m_strAddress1) & "','" &

> SQLEncode(m_strAddress2) & "','" & _

>              SQLEncode(m_strCity) & "','" & SQLEncode(m_strState_code) &

> "','" & SQLEncode(m_strCountry_code) & "','" & SQLEncode(m_strZip) & "','"

> & SQLEncode(m_strFederalTaxID) & "'," & _

>              IIf(m_intIndustry_code = 0, "NULL", m_intIndustry_code) & _

>              ",'" & SQLEncode(m_strIndustry_other) & "'," & _

>              IIf(m_intBusinessType_code = 0, "NULL",

> m_intBusinessType_code) & ",'" & SQLEncode(m_strBusinessType_other) &

> "','" & _

>              SQLEncode(m_strYearsInBusiness) & "','" &

> SQLEncode(m_strNumberOfEmployees) & "','" & SQLEncode(m_strAnnualSales) &

> "','" & SQLEncode(m_strNoOfActiveCustomers) & "','" & _

>              SQLEncode(m_strAverageInvoiceSize) & "'," &

> mm_blnPresentlyFactored & "," & _

>              IIf(m_blnPresentlyFactored, "'" &

> SQLEncode(m_strNameOfFactor) & "'", "NULL") & "," &

> mm_blnPresentlyFinanced & "," & _

>              IIf(m_blnPresentlyFinanced, "'" &

> SQLEncode(m_strNameOfLender) & "'", "NULL") & "," & mm_blnSecurityInterest

> & "," & _

>              IIf(m_blnSecurityInterest, "'" &

> SQLEncode(m_strNameOfSecuredParty) & "'", "NULL") & ",'" & _

>              SQLEncode(m_strProducts_Services) & "'," & _

>              IIf(m_intInfSource_code = 0, "NULL", m_intInfSource_code) &

> ",'" & SQLEncode(m_strInfSource_other) & "','" & SQLEncode(m_strComments)

> & "'" & ")"

> 

>     cn.Execute strSql

>     Set cn = Nothing

>     objContext.SetComplete

>     Exit Function

> ErrorHandler:

>     If Not cn Is Nothing Then Set cn = Nothing

>     objContext.SetAbort

>     Err.Raise Err.Number, "RequestInformation.AddToTable()",

> Err.Description

> End Function

> 

> Private Function SQLEncode(str As String) As String

>     If IsNull(str) Or str = "" Then

>     

>     Else

>         str = Replace(str, "'", "''")

>     End If

>     SQLEncode = str

> End Function

> End COM --->

> 

  Return to Index