.NET service
Ok im going crazy trying to get my service to run a SQL Stored Procedure with a parameter. Here is the code.
Dim conn As New SqlConnection("Data Source=Server;Initial Catalog=Mytable;Integrated Security=True")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
conn.Open()
cmd.Connection = conn
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.CommandText = "Citation_Pull"
cmd.Parameters.Add("@CitationNumber", Data.SqlDbType.VarChar).Value = e.Name.ToString
dr = cmd.ExecuteReader
What happens is the service sees a new file in a folder, pulls the name and sends that name onto the SP to run. And this is kicking my butt, ive been on this quite a few days. And i cant get it to run..
[822 byte] By [
BrownRJ] at [2007-11-11 8:43:41]

# 3 Re: .NET service
Um, how can people help if you haven't told them how it fails?
Hmm Fails as in it does not work. It does not connect, does not run the Stored procedure, does not insert any of the information into the table. I made the stupid assumption that if i had the connection string wrong somebody would tell me. Does any of that code look wrong to you?
But at this point I dont think its a coding issue.
# 4 Re: .NET service
In your connection string you are specifying 'Integrated Security'. If your service is running under the Local System Account or Network Service account you will probably NOT connect to SQL Server with those credentials.
Try changing the connection string to include a named SQL Server user and password and see if that works. The syntax is:
User ID=username;Password=userpassword;
Alternately, you can set the service up to run under a named user account that has connectivity to SQL Server.
Hope this helps... :cool: