TN IT309 How to Connect to a SQL Database in InTouch
Last updated: February 20th, 2025Description
- Author: Brian Schneider
- Published: February 20th, 2025
Details:
Description
This article from InSource Solutions shows you how to connect to a SQL database inside of InTouch.
- Author: Daniel London
- Published: 03/06/2018
- Applies to: InTouch
Details
This article will walk you through how to use the SQLConnect() function to connect to a SQL database inside of InTouch.
The syntax for the script function is below:
SQLConnect(iConnectionId, mConnectString);
iConnectionID = A memory integer tag defined inside of InTouch that holds the connection ID number from SQL Server.
mConnectString = This is a memory message tag where the connection string is referenced in another part of the script/application. You can also type the full connection string information instead of using a message tag.
The connection string we will be using is:
mConnectionString = "Provider = SQLOLEDB.1; User ID = sa; Password = sa; Initial Catalog = SQL App; Data Source = DLTESTSVR";
Below is the script that will be used to connect to the database. I assigned this to an action animation for a pushbutton.
Line 1: I am assigning my connection string to the message tag that I defined.
Line 2: I am using the SQLConnect() function based on the syntax that was described earlier in this article.
Line 3: A memory message tag that I tied to a label to show if the script executes to list the status as connected.