CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeCharge.Discussion

 CC Variables and ActiveX components

Print topic Send  topic

Author Message
Jim Ryan
Posted: 09/03/2001, 3:11 PM

I built a activex dll component that gets information from a record and
opens a Word document template and fills in the information from the
database record. The problem I'm having is trying to get the information off
the server database. From my own computer the code works fine as long as the
database resides on my PC.
I've tried changing the SET oConn = Server.CreateObject("ADODB.Connection"),
but when I try to package the script I get errors. Same with the
Server.CreateObject ("ADODB.Recordset").

What I would really like to do is create the dll and use the CC connection
and variables to connect to the server database.
Could I put the code somewhere else in CC? For example in the modules
section? If so where? Anyone have any ideas?
I've been working on this for over a week and can't figure it out. Please
help!!

Jim

Here's the code I put in the custom header section of the CC page:

<OBJECT ID="invoice"
CLASSID="CLSID:25F9D2E4-B7A0-4730-978F-4CBA7151A638"
CODEBASE="http://myserver/invoice/package/AutomateWord.CAB#version=1,0,0,0">
</OBJECT>

Here's the code I put in the Header section of the form:

Click the button to view the invoice for the order:
<P/><LABEL TYPE="text" VALUE="1" ID="ID">
<P/><BUTTON ID="InvoiceButton">Create Invoice</BUTTON>
</BODY>

<SCRIPT Language="VBScript">

Function InvoiceButton_OnClick()
Dim strConn
strConn = "provider=microsoft.jet.oledb.4.0; data source=" & _
"c:\Inetpub\wwwroot\invoice\fpdb\invoice.mdb"

invoice.GetData ID.Value, strConn
invoice.MakeInvoice "http://myserver/invoice/invoice.doc"
End Function

</SCRIPT>

Here's the code for the Activex dll:

Public Sub GetData(sID As Variant, strConn As Variant)

Dim oConn As Object, RS As Object

'Connect to the database. This is where I'd like to connect to the
database through CodeCharge.
Set oConn = CreateObject("ADODB.Connection")
oConn.Open strConn

'Obtain the record ID and all fields.This is where I'd like to get the
record through CodeCharge

Set RS = CreateObject("ADODB.Recordset")
RS.Open "SELECT [ID], [Short_Desc], [App_Des_Data], [App_Replace_for],
[App_Means], " & _
"[Eligibility], [Aero_PN], [Supplement_No], [Qty], [Serial_batchno],
[Status_work], " & _
"[Items], [Name], [Faa_auth_no], [Date], [System_ref_no], [Salesorder],
[ordernumber] " & _
"From tbl8130word WHERE " & _
"[ID]=" & sID, oConn, 3 'adOpenStatic=3

m_Data.ID = sID
m_Data.Date = CDate(RS.Fields("Date").Value)
m_Data.Aero_PN = RS.Fields("Aero_PN").Value
m_Data.App_Des_Data = RS.Fields("App_Des_Data").Value
m_Data.App_Means = RS.Fields("App_Means").Value
m_Data.App_Replace_for = RS.Fields("App_Replace_For").Value
m_Data.Eligibility = RS.Fields("Eligibility").Value
m_Data.Faa_auth_no = RS.Fields("Faa_auth_no").Value
m_Data.Items = RS.Fields("Items").Value
m_Data.Name = RS.Fields("Name").Value
m_Data.ordernumber = RS.Fields("ordernumber").Value
m_Data.Qty = RS.Fields("Qty").Value
m_Data.Salesorder = RS.Fields("Salesorder").Value
m_Data.Serial_batchno = RS.Fields("Serial_batchno").Value
m_Data.Short_Desc = RS.Fields("Short_Desc").Value
m_Data.Status_work = RS.Fields("Status_work").Value
m_Data.Supplement_No = RS.Fields("Supplement_No").Value
m_Data.System_ref_no = RS.Fields("System_ref_no").Value

RS.Close

'Close the connection to the database
oConn.Close

End Sub



Public Sub MakeInvoice(sTemplate As Variant, Optional bSave As Variant)

Dim oWord As Object
Dim oDoc As Object
'Dim oTable As Object

If IsMissing(bSave) Then bSave = False

'Open the document as read-only
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open(sTemplate, , True)

'Fill in the bookmarks on the tag

oDoc.Bookmarks("Short_Desc").Range.Text = m_Data.Short_Desc
oDoc.Bookmarks("App_Means").Range.Text = m_Data.App_Means
oDoc.Bookmarks("Eligibility").Range.Text = m_Data.Eligibility
oDoc.Bookmarks("Aero_PN").Range.Text = m_Data.Aero_PN
oDoc.Bookmarks("Qty").Range.Text = m_Data.Qty
oDoc.Bookmarks("Serial_Batchno").Range.Text = m_Data.Serial_batchno
oDoc.Bookmarks("Status_work").Range.Text = m_Data.Status_work
oDoc.Bookmarks("Item").Range.Text = m_Data.Items
oDoc.Bookmarks("Name").Range.Text = m_Data.Name
oDoc.Bookmarks("Faa_auth_no").Range.Text = m_Data.Faa_auth_no
oDoc.Bookmarks("Date").Range.Text = m_Data.Date
oDoc.Bookmarks("System_ref_no").Range.Text = m_Data.System_ref_no
oDoc.Bookmarks("Salesorder").Range.Text = m_Data.Salesorder
oDoc.Bookmarks("ordernumber").Range.Text = m_Data.ordernumber


If bSave Then
'Save the document as "c:\8130-3.doc" and quit Word
Dim nResult As Long
nResult = MsgBox("Are you sure you wish to create the document" & _
" ""c:\8130-3.doc""? If this document already exists, " & _
"it will be replaced", vbYesNo, "AutomateWord")
If nResult = vbYes Then oDoc.SaveAs "c:\8130-3.doc"
oDoc.Close False
oWord.Quit
Else
'Make Word visible
oWord.Visible = True
End If

End Sub






   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.