Here is my sample code:
public static class MySqlHelper
{
private static string constring = ConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString;
public static int ExecuteNonQuery(string mysqlquery)
{
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(mysqlquery, conn);
int result;
try
{
conn.Open();
result= cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
return result;
}
}
Using: MySqlHelper.ExecuteNonQuery("select * from customers");
I would like to know the problems using this static class.
I can change my class as mentioned here , but I have used this class in several websites and it will take me a couple of days to change it in all places and check this out.
Thanks for any inputs.
Edit: Updated code. Does this mean that answers are provided? Sorry, I should have published at the beginning.
source
share