Aaargh! OnLoad event!!!

T

Trevor Spenglehoff

Hi,

I'm trying to get the OnLoad programming to query an SQL 2000 database's
stored procedure to return a value. I have set up the necessary table and
credentials on the SQL server and that seems fine.

Having found a script which will do this (but not able to trace its author)
I keep getting the following error (apologies if this query is in the wrong
section, but I'm working in InfoPath and this is driving me insane):

InfoPath cannot open the selected form because of an error in the form's code.
The following error occurred:

Expected ';'
File:script.js
Line:46
{Dim CN as SqlDataSource


The actual OnLoad script is as follows:

/*
* This file contains functions for data validation and form-level events.
* Because the functions are referenced in the form definition (.xsf) file,
* it is recommended that you do not modify the name of the function,
* or the name and number of arguments.
*
*/

// The following line is created by Microsoft Office InfoPath to define the
prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-03-15T12:24:24" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
//</namespacesDefinition>


//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/dfs:myFields/dfs:dataFields/d:tblMyID/@MyID
// Note: Information in this comment is not updated after the function
handler is created.
//=======
function msoxd__NewID__MyID_attr::OnAfterChange(eventObj)
{
// Write code here to restore the global state.

if (eventObj.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}

// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.

}

//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/my:myFields/my:txtNew
// Note: Information in this comment is not updated after the function
handler is created.
//=======

function XDocument::OnLoad(eventObj)
{Dim CN as SqlDataSource
If Xdocument.IsNew Then
Set CN = CreateObject("ADODB.Connection")
With CN
.Provider = "SQLOLEDB"
.ConnectionString = "Data Source=ACER1;Initial Catalog=Travel;Integrated
Security=SSPI"
.Open
.Execute "mysp_NewID"
End With
XDocument.DataAdapters("NewID").Query
End If
}
 
T

Trevor Spenglehoff

Excellent - you have saved me from banging my head against a brick wall -
many, MANY thanks!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top