public static Exec ( String statement, String connectionStringName, |
||
statement | String | SQL statement to execute. |
connectionStringName | String | Name of a connection string in the Web.config file. |
timeout | Timeout in seconds for the command to execute; use zero for no timeout period. | |
return | System.Boolean |
public static Boolean Exec(String statement, String connectionStringName, Int32 timeout)
{
Boolean retVal = false;
if (!String.IsNullOrEmpty(statement))
{
try
{
using (SqlConnection cn = new SqlConnection(ConnectionString(connectionStringName)))
{
cn.Open();
using (SqlCommand oc = new SqlCommand(statement, cn))
{
oc.CommandTimeout = timeout;
oc.ExecuteNonQuery();
}
}
retVal = true;
}
catch (Exception err)
{
throw new Exception("Halide.H3Sql Error: " + err.ToString());
}
}
return retVal;
}