<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Database Connection with login prompt in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/665057#M85348</link>
    <description>&lt;P&gt;If I remember correctly this has some ideas&amp;nbsp;&lt;LI-MESSAGE title="How to handle user password information in JSL ( ODBC connection strings )" uid="627942" url="https://community.jmp.com/t5/Discussions/How-to-handle-user-password-information-in-JSL-ODBC-connection/m-p/627942#U627942" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2023 10:06:33 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-08-03T10:06:33Z</dc:date>
    <item>
      <title>Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86285#M38470</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been working on a script which connects to a database system and then pulls some data.&lt;/P&gt;
&lt;P&gt;The script works fine using my credentials however as these credentials change every couple of months due to the password having to be updated, I am often having to change the script. We are also looking at pushing this script down the route of validation, which means that we wouldn't be able to change the script once it is validated. I want to therefore add a prompt so that anybody could use this script and it would ge through validation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Below is the script currently (the UID and password are the details that would need to be inputted):&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Dt1=Open Database(
"DSN=MACPAC;SYSTEM=MEDIUK;UID=INSERT;PASSWORD=INSERT;DBQ=MPDAT10;DFTPKGLIB=QGPL;LANGUAGEID=ENU;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;QRYSTGLMT=-1;",
       "Select ixplot as batchid,
ixppn as product_part_no,
ixrecq as batch_size,
ixlevl as macpac_level,
ixcpn as comp_part_no,
ixcpde as comp_desc,
ixclot as comp_lot_no,
ixcmpo as comp_order_no,
ixissq as comp_qty,
ixvend as vendor_code,
ixvlot as vendor_lot_no,
ixseqn as sequence        
FROM \!"MPDAT10\!".\!"ICM860P\!""
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If somebody could help me in finding a way to add a prompt then that would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:48:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86285#M38470</guid>
      <dc:creator>JacobPardew</dc:creator>
      <dc:date>2018-12-21T15:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86288#M38473</link>
      <description>&lt;P&gt;Probably something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

nw = NewWindow("Cooext To Database",
		PanelBox("Input your credentials",
			LineUpBox(NCol(2),
				TextBox("User:"),
				teb1 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200)),
				TextBox("Password:"),
				teb2 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200), &amp;lt;&amp;lt; passwordStyle(1))
				);
			),
		LineUpBox(NCol(2),
			ButtonBox("OK", OKscript),
			ButtonBox("Cancel", nw &amp;lt;&amp;lt; closeWindow)
			);
		);

OKScript =
Expr(
	nw &amp;lt;&amp;lt; closeWindow;
	user = teb1 &amp;lt;&amp;lt; getText;
	pass = teb2 &amp;lt;&amp;lt; getText;
	// DB connection info . . .
	Speak("User was "||user, wait(1));
	Speak("Password was "||pass, wait(1));	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Dec 2018 16:56:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86288#M38473</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-12-20T16:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86337#M38487</link>
      <description>&lt;P&gt;Hi Ian,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for getting back to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know how you would be able to use this new prompt box but to sandwich this into my current code? So that the box appears, we then input the ID and password and then that is put into the line of code where we are then connecting to the database?&lt;/P&gt;
&lt;P&gt;I have tried to use "teb1" and "user" both with and without quotations. Surely I must be a missing a little something which means that it isn't working?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see that the prompt works for the passowrd however I cannot work out how to get this to then put the password into the database query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);
nw = NewWindow("Cooext To Database",
PanelBox("Input your credentials",
LineUpBox(NCol(2),
TextBox("User:"),
teb1 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200)),
TextBox("Password:"),
teb2 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200), &amp;lt;&amp;lt; passwordStyle(1))
 
);
),
LineUpBox(NCol(2),
ButtonBox("OK", OKscript),
ButtonBox("Cancel", nw &amp;lt;&amp;lt; closeWindow)
 
);
);
OKScript =
Expr(
nw &amp;lt;&amp;lt; closeWindow;
user = teb1 &amp;lt;&amp;lt; getText;
pass = teb2 &amp;lt;&amp;lt; getText;
// DB connection info . . .
Speak("User was "||user, wait(1));
Speak("Password was "||pass, wait(1));
 
);
Dt1=Open Database(
"DSN=MACPAC;SYSTEM=MEDIUK;UID=(HOW TO GET UID HERE?);PASSWORD=(HOW TO GET PASSWORD HERE?;DBQ=MPDAT10;DFTPKGLIB=QGPL;LANGUAGEID=ENU;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;QRYSTGLMT=-1;",
"Select ixplot as batchid,
ixppn as product_part_no,
ixrecq as batch_size,
ixlevl as macpac_level,
ixcpn as comp_part_no,
ixcpde as comp_desc,
ixclot as comp_lot_no,
ixcmpo as comp_order_no,
ixissq as comp_qty,
ixvend as vendor_code,
ixvlot as vendor_lot_no,
ixseqn as sequence
FROM \!"MPDAT10\!".\!"ICM860P\!""
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jacob&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 15:49:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86337#M38487</guid>
      <dc:creator>JacobPardew</dc:creator>
      <dc:date>2018-12-21T15:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86338#M38488</link>
      <description>&lt;P&gt;I tend to like a non-modal UI, so was assuming that your code would go into 'OKscript' above.&lt;/P&gt;
&lt;P&gt;If you want to put the dialog inline with existing code, you need to make a few small changes.&lt;/P&gt;
&lt;P&gt;Be aware that there are other (better?) ways to build the DB connection string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// Your first code block
Speak("First code block", wait(1));

// Using a 'modal' window delays execution of subsequent code until input is given
nw = NewWindow("Connect To Database", &amp;lt;&amp;lt; Modal, &amp;lt;&amp;lt; returnResult,
		PanelBox("Input your credentials",
			LineUpBox(NCol(2),
				TextBox("User:"),
				teb1 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200)),
				TextBox("Password:"),
				teb2 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200), &amp;lt;&amp;lt; passwordStyle(1))
				);
			),
		LineUpBox(NCol(2),
			ButtonBox("OK"),
			ButtonBox("Cancel")
			);
		);

// Your second code block
// Stop if the user canecls . . .
if(nw["Button"] == -1, Speak("User Cancelled"); Stop());
// . . . else get the values the user gave
user = nw["teb1"];
pass = nw["teb2"];
DBconnectionString = "User is "||user||" password is "||pass;
Speak(DBconnectionString);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 11:33:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86338#M38488</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-12-21T11:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86546#M38586</link>
      <description>&lt;P&gt;Would your database people be happy with this sort of solution?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create an application account on the database that has the necessary privs, whose password never expires.&lt;/LI&gt;
&lt;LI&gt;Create an &lt;U&gt;&lt;STRONG&gt;encrypted&lt;/STRONG&gt;&lt;/U&gt; jsl file that defines the function GET_DBC.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;The GET_DBC function calls CREATE DATABASE CONNECTION using the proper dsn string, and returns the database connection.&lt;/LI&gt;
&lt;LI&gt;In your main program you would make calls to EXECUTE SQL using the database connection&lt;/LI&gt;
&lt;LI&gt;When you're all done call CLOSE DATABASE CONNECTION.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Here's a simple version of GET_DBC.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*
File Name: 		Get_DBC.JSL
Description:    Function to get database connection string
*/
get_dbc = function({}, {default local},

	my_dbc = "";
	dsn_string = "Driver={Oracle in OraClient12Home1};Dbq=MY_TNS_ENTRY;UID=USERNAME;PWD=PASSWORD;";
	my_dbc = create database connection(dsn_string);

// Return the connection to Oracle
	my_dbc;
);	// end Get_DBC.JSL&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Dec 2018 19:30:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/86546#M38586</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-12-31T19:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/99088#M38784</link>
      <description>&lt;P&gt;Hi Ian,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for replying to my&amp;nbsp;question. I see that this produces the dialog box and saves the password that I input but I am still unsure as to how I am then suppose to feed this into the code below when connecting to the database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for being a pain, you have been&amp;nbsp;very helpful!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);
 
// Your first code block
Speak("First code block", wait(1));
 
// Using a 'modal' window delays execution of subsequent code until input is given
nw = NewWindow("Connect To Database", &amp;lt;&amp;lt; Modal, &amp;lt;&amp;lt; returnResult,
PanelBox("Input your credentials",
LineUpBox(NCol(2),
TextBox("User:"),
teb1 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200)),
TextBox("Password:"),
teb2 = TextEditBox("", &amp;lt;&amp;lt; setWidth(200), &amp;lt;&amp;lt; passwordStyle(1))
 
);
),
LineUpBox(NCol(2),
ButtonBox("OK"),
ButtonBox("Cancel")
 
);
);
// Your second code block
// Stop if the user canecls . . .
if(nw["Button"] == -1, Speak("User Cancelled"); Stop());
 
// . . . else get the values the user gave
user = nw["teb1"];
pass = nw["teb2"];
DBconnectionString = "User is "||user||" password is "||pass;
Speak(DBconnectionString);
MACPAC_CHARTGEN = Function( {},/* Tell MACPAC to open the materials data from a certain table*/
Dt1=Open Database(
"DSN=MACPAC;SYSTEM=MEDIUK;UID=||user||;PASSWORD=||pass;DBQ=MPDAT10;DFTPKGLIB=QGPL;LANGUAGEID=ENU;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;QRYSTGLMT=-1;",
"Select ixplot as batchid,
 
ixppn as product_part_no,
ixrecq as batch_size,
ixlevl as macpac_level,
ixcpn as comp_part_no,
ixcpde as comp_desc,
ixclot as comp_lot_no,
ixcmpo as comp_order_no,
ixissq as comp_qty,
ixvend as vendor_code,
ixvlot as vendor_lot_no,
ixseqn as sequence
FROM \!"MPDAT10\!".\!"ICM860P\!""
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 16:32:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/99088#M38784</guid>
      <dc:creator>JacobPardew</dc:creator>
      <dc:date>2019-01-07T16:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/99146#M38785</link>
      <description>&lt;P&gt;The double vertical bars ('||') tell JMP to concatenate two character strings. So try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"DSN=MACPAC;SYSTEM=MEDIUK;UID="||user||";PASSWORD="||pass||";DBQ=MPDAT10;DFTPKGLIB=QGPL;LANGUAGEID=ENU;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;QRYSTGLMT=-1;"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 16:44:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/99146#M38785</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2019-01-07T16:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/665056#M85347</link>
      <description>&lt;P&gt;On my system (v17.1), looking at the data sets which store the query results, there are tables scripts &lt;STRONG&gt;Source, Update from DB, Save to DB&amp;nbsp;&lt;/STRONG&gt;with the password in plain text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The generation of such Tables scripts can be deactivated in the preferences via&amp;nbsp;&lt;SPAN&gt;Tables &amp;gt; &lt;STRONG&gt;Hide ODBC Connection String.&lt;BR /&gt;&lt;A href="https://community.jmp.com/t5/JMP-Knowledge-Base/Database-table-scripts-Update-from-Database-Modify-etc-or/ta-p/621050" target="_blank"&gt;Jmp Note 621050&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bis is there an option to prevent a user from deactivating&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;Hide ODBC Connection String&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;,&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;running &lt;FONT face="courier new,courier"&gt;Execute SQL(my_dbc, ...)&lt;/FONT&gt; and getting the password from the table scripts.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 09:39:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/665056#M85347</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-08-03T09:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Database Connection with login prompt</title>
      <link>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/665057#M85348</link>
      <description>&lt;P&gt;If I remember correctly this has some ideas&amp;nbsp;&lt;LI-MESSAGE title="How to handle user password information in JSL ( ODBC connection strings )" uid="627942" url="https://community.jmp.com/t5/Discussions/How-to-handle-user-password-information-in-JSL-ODBC-connection/m-p/627942#U627942" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 10:06:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Database-Connection-with-login-prompt/m-p/665057#M85348</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-08-03T10:06:33Z</dc:date>
    </item>
  </channel>
</rss>

