DNN Custom Forms by OnyakTech
OnyakTech Custom Forms DNN Module
by OnyakTech

OnyakTech Forms DNN Module Database Access

There are several ways to connect your custom DNN form to a database, by using Tokens in your custom form template or by setting the database options in Display Setup. The best method is to set these options in Display Setup. Using tokens to configure the database access can be easier if you need to share the same form across multiple DNN web sites, however there are additional restrictions when using the tokens due to some DNN HTML editors and these can cause unexpected results. If you are not an advanced DNN user it is recommended to use the Display Setup to set the database options.

Simple and Fast Database Setup

OnyakTech Forms DNN module is very easy to use due to many powerful features and this is one of them. If you want your forms to save to the database and you don't have specific requirements for the table or how it does this then you will want to check the option Save to Database in Display Setup under "Form Data Options". That's it! OnyakTech Forms will handle everything for you. It will create a table for your form including columns, data types, primary keys, insert scripts, update scripts, delete scripts, etc. The name of the table is based on your form name, the standard is: OnyakTech_Forms_PortalId_FormNameHere.

Advanced Database Setup

For more control over the database actions you will use the additional options in Display Setup under the "Form Data Options" section. In this section you can set the primary key, table name, connection string, etc.

Connection String: If you leave the Connection String empty the Forms DNN module will use your DNN database connection. To define your own connection you will enter that into this option in Display Setup. There are sample connection strings you can use located at the bottom of Display Setup in the Tips and Tricks section. Don't forget to define the type of connection by checking "Use ODBC" or "Use OLE". If your database is Microsoft SQL Server then you can leave those options unchecked.

Table Name and Primary Key: Providing a Table Name and Primary Key will override the defaults for the Forms module and your form. Note that the OnyakTech DNN Forms module will add columns for controls if a column name matching the control name doesn't yet exist in the table. It will also add a primary key to the table if one is not found but only if the database is Microsoft SQL Server. The primary key must be an Identity, the seed can be set to anything you wish it to be.

PK LookUp: (Primary Key LookUp) This option allows you to use SQL that will be executed to locate the primary key value that will be used to load the form data. The SQL Statement you use is parsed which means you can use tokens in your SQL that include values from the current user if they are logged in, query string, cookies and the current users session values.

Form Load SQL Override: Enter custom SQL here to override the default method for loading data into your controls when the Form is loaded. All data columns will be mapped to matching Controls by name. For example, if you have a column named "Address" then you should also have a control named Address with the token [TEXTBOX-ADDRESS].

TSQL Execute After Submit: The TSQL Execute After Submit feature will execute the TSQL you enter into this option after a form is submitted. In the TSQL you can use value tokens to pass the form values submitted in your TSQL. For example, if you have a control on your form indicated as [TEXTBOX-MYNAME] and you want to pass that to a stored procedure after the form is submitted your TSQL would look something like the following: exec MyStoredProcedure @UserName=[MYNAME]; To pass the IDENTITY of the database transaction from Form Submit use the token [IDENTITY]

Note that the Event Manager for the Custom Forms DNN Module will use the connection string you set in Display Setup when executing events that require database access. If the connection string is not defined then it will use the connection string for DNN.