I
I appreciate your help.... anony
Hi all,
Ive made a Windows Service that basically makes connections to a Sql
database, when it connects it runs a stored procedure. Below is the
static procedure. This procedure is in the Windows Service and the
procedure runs and an Eventlog is successfully written with no
exceptions. If I take this simple code and put it in a test console
app with the same connection, stored procedure and email address it
runs no problem. The problem I have is that I get no errors so im
thinking its some kind of Threading issue?
I just dont understand why this code with the same parameters can work
fine in a stand alone console app rather than incorporated into a
windows service. And still the windows service doesn't give me any
error, and the stored procedure doesn't run! I have verified that the
stored procedure is there and works!
static void runme(string connection, string remove, string
emailaddresss)
{
try
{
SqlConnection con = new SqlConnection(connection);
SqlCommand com = new SqlCommand(remove);
com.CommandType= CommandType.StoredProcedure;
SqlParameter myParm = new
SqlParameter("@email",SqlDbType.NVarChar,25);
myParm.Value = emailaddress;
com.Parameters.Add(myParm);
con.Open();
com.Connection = con;
com.ExecuteNonQuery();
con.Close();
com = null;
con = null;
EventLog.WriteEntry("MMS", " " + connection + " " +
remove + " " +emailaddress);
}
catch(System.Exception e)
{
EventLog.WriteEntry("Service", "Exception is as
follows: " ex.Message);
}
}
Thanks very much for your help.
phil
Ive made a Windows Service that basically makes connections to a Sql
database, when it connects it runs a stored procedure. Below is the
static procedure. This procedure is in the Windows Service and the
procedure runs and an Eventlog is successfully written with no
exceptions. If I take this simple code and put it in a test console
app with the same connection, stored procedure and email address it
runs no problem. The problem I have is that I get no errors so im
thinking its some kind of Threading issue?
I just dont understand why this code with the same parameters can work
fine in a stand alone console app rather than incorporated into a
windows service. And still the windows service doesn't give me any
error, and the stored procedure doesn't run! I have verified that the
stored procedure is there and works!
static void runme(string connection, string remove, string
emailaddresss)
{
try
{
SqlConnection con = new SqlConnection(connection);
SqlCommand com = new SqlCommand(remove);
com.CommandType= CommandType.StoredProcedure;
SqlParameter myParm = new
SqlParameter("@email",SqlDbType.NVarChar,25);
myParm.Value = emailaddress;
com.Parameters.Add(myParm);
con.Open();
com.Connection = con;
com.ExecuteNonQuery();
con.Close();
com = null;
con = null;
EventLog.WriteEntry("MMS", " " + connection + " " +
remove + " " +emailaddress);
}
catch(System.Exception e)
{
EventLog.WriteEntry("Service", "Exception is as
follows: " ex.Message);
}
}
Thanks very much for your help.
phil