Submitting to a database with long data types

J

jared.winick

There are many post regarding InfoPath not allowing submission to
databases with long data types (Memo, for example).

Some of these posts are:

http://groups.google.com/group/micr...ath+submit+long&rnum=1&hl=en#eaa033e7eb438373
http://groups.google.com/group/micr...ath+submit+long&rnum=2&hl=en#a4e88cfd653f0c8f
http://groups.google.com/group/micr...ath+submit+long&rnum=3&hl=en#28709f9d344486c0
http://groups.google.com/group/micr...ath+submit+long&rnum=5&hl=en#27fb68884cbc71d1

As I had the same problem, but never found a posted solution, I wanted
to post a way around this limitation.

First, create a Button in the Design mode of InfoPath. In the "Action"
dropdown, select "Rules and Custom Code". Then click the button labeled
"Edit Form Code...". This will launch Microsoft Script Editor, and will
automatically create an event handler to handle the onClick event for
your button.

The following is a JScript sample of how to take the text from a
TextField (which may have over 255 characters) and insert this text
into a Memo field in a Access database table.

function CTRL32_7::OnClick(eventObj)
{
var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Test.mdb";
var dbConnection = new ActiveXObject("ADODB.Connection");
dbConnection.ConnectionString = connectionString;
dbConnection.Open();

var rsRecordset = new ActiveXObject("ADODB.Recordset");
var sqlCommand = new ActiveXObject("ADODB.Command");
sqlCommand.ActiveConnection = dbConnection;

var notesField =
XDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:Test/@OtherNotes");

//XDocument.UI.Alert(notesField.text);

var sSQL = "INSERT INTO Test VALUES ('" + notesField.text + "')";
sqlCommand.CommandText = sSQL;
sqlCommand.Execute();
}

Hope this is helpful. The InfoPath SDK is good reading before writing
any custom script. Thanks.

Jared Winick
 

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