WinBatch® Technical Support Forum

All Things WinBatch => WebBatch => Topic started by: Jeff on May 29, 2019, 07:31:34 AM

Title: SQL Connection String
Post by: Jeff on May 29, 2019, 07:31:34 AM
Hi all.
I am tinkering with WebBatch for the first time and doing a small project to get an understand of it. I am connecting to a SQL server database and pulling the DB information as expected. <I am proud!>

My current problem is the connection string is sitting in plain text with a SQL user name and password. I do not have the option to use domain authentication as part of the connection string. So, is there a way to hide or encrypt the connection string so the SQL username and password is not sitting in plain text?

SQLConn.ConnectionString = "Provider=SQLOLEDB;Data Source=MyServer;Initial Catalog=MyDataBase;User ID=MyUserId;Password=MyPassword"

Title: Re: SQL Connection String
Post by: td on May 29, 2019, 08:07:45 AM
You could split your script into separate scripts and compile the script with sensitive information using the "Encode for calls from EXE files" compiler option.  You can then call the compiled .wbc file from a plan text .web script.
Title: Re: SQL Connection String
Post by: Jeff on May 29, 2019, 08:13:27 AM
Ok, I like the thought process, but I have some questions.

Can I call another exe from a WEBBATCH script?

Where is the material on making this work?
Title: Re: SQL Connection String
Post by: td on May 29, 2019, 08:50:29 AM
You do not need to call "another exe" to call a compile .wbc file from WebBatch script.  You just use the WIL Call function to execute the encoded script from your WebBatch script. You treat the .wbc file just like you would any other script you execute using the WIL Call function.

Not sure what you mean by "material" but the compiler is documented in the Consolidated WIL Help file.  Go to:

Home > WinBatch Users Guide > Compiler > Compile Options > Encode for Call's from EXE files
Title: Re: SQL Connection String
Post by: Jeff on May 29, 2019, 09:12:14 AM
Thanks-I just need to find the reading material or an example.
Title: Re: SQL Connection String
Post by: td on May 29, 2019, 09:32:09 AM
There isn't "reading material" specific to calling a .wbc file from a script.  This is because the concept and implementation are very simple.  If you are not familiar with the WIL Call function, read about it in the Consolidated WIL Help file. The function is used in many places in the Tech Database.  Once you understand calling one script from another you just need to use the WinBatch Compiler to create an encrypted version of the script you want to call and then call it using the WIL Call function.