Tim Maxey .NET Technology Blog & Resources

September 2011 Entries

Could not find stored procedure

I haven't had to use a direct call to a stored procedure in a long time, but came across the could not find stored procedure error. (And yes I had all security set fine). If I uncommented out the "commandType" it worked! Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("myconnection").ConnectionString)         Dim cmd As New SqlCommand         Dim execStr As String = "EXEC dbo.InsertActivity " & userid         cmd.CommandText = execStr         'cmd.CommandType = CommandType.StoredProcedure DOES NOT WORK WITH THIS UNCOMMENTED, WEIRD         cmd.Connection = conn         conn.Open()         cmd.ExecuteNonQuery()         conn.Close()         cmd.Dispose()