If i have a dll
which i use in many web applications to use methods in this dll
in my applications.
What 's the best practice to handle the connection string ?
The dll
methods are static methods ..
this is what i do
private static String connectionString = "User Id=xxx;Password=xxx;Host=xxx;Server=xxx;Service=1525;Database=xxx; Client Locale=ar_ae.1256; Database Locale=ar_ae.8859-6; Protocol=olsoctcp;pooling=true;Min Pool Size=4;Max Pool Size=400;Connection Timeout=30";
public static int Is_Valid_User(string p_u, string p_p)
{
int ret = 0; // invalid user
using (IfxConnection conn = new IfxConnection(connectionString))
{
IfxCommand DBCmd = new IfxCommand();
String p = My_Decryption_2(p_p);
try
{
if (conn.State == ConnectionState.Closed)
conn.Open();
DBCmd = new IfxCommand();
DBCmd.Connection = conn;
DBCmd.CommandText = "SELECT nvl(emp_num,0) FROM emp_net WHERE username = ? AND DECRYPT_CHAR(password, 'xxxxxx') = ? ";
DBCmd.Parameters.Add("user_name", p_u);
DBCmd.Parameters.Add("password", p);
using (IfxDataReader dataReader = DBCmd.ExecuteReader())
{
if (dataReader.Read())
ret = (int)dataReader[0];
dataReader.Close();
}
}
catch (ApplicationException e)
{
}
conn.Close();
}
return ret;
}
Is this a good way to use a dll
in my web application ?or there 's a way better than this ?