SqlCommand C# Issue?

This was it. Wrapping it in using definitely helped, but dumb me missed something so obvious. Thanks ck for pointing it out.. Ran the process all weekend did not get the error.

– AskaQn Jun 15 '09 at 3:26.

HI The code seems OK (I recommend that you use the using clause as demonstrated to you in a previous answrer). I wonder if the problem is notfrom within the stored procedure. Try to debug it, or at least add some log recording atthe begining and end of your stored procedure to make sure that it exits OK every time.

This is a good idea - remember, the error you see is sometimes the result of a deeper error that has bubbled up to the point where it gets reported. In this case, since the code usually works, you should look at external (database) influences. – Doug L.

Jun 12 '09 at 8:48.

Using(sqlcon = new SqlConnection(strSqlconnection)) { using(SqlCommand sqlcomSMCheckin = new SqlCommand("dbo. Prc_CheckIn", sqlcon)) { sqlcomSMCheckin. CommandType = CommandType.

StoredProcedure; sqlcomSMCheckin.Parameters. Add("@Description", SqlDbType. VarChar, 50) .

Value = "My App"; sqlcomSMCheckin. CommandTimeout = this. ICommandTimeOut; sqlcon.Open(); sqlcomSMCheckin.ExecuteNonQuery(); sqlcon.Close(); } } I replace "prc_CheckIn" with "dbo.

Prc_CheckIn", I specify a max length on the VARCHAR parameter (adjust as needed), wrapped everything in using {} blocks - that's about it. Do you still get the same error?Marc.

Yup. Made all the changes mentioned and am still getting the error. Added the database qualification also for the sp.So it is abc.dbo.

Prc_CheckIn now. The code runs every 20 secs and it runs fine for several minutes and then all of a sudden I get this. I should mention that the method this code is in is used by multiple threads.

– AskaQn Jun 12 '09 at 5:51.

Make sure the sproc "prc_CheckIn" exist in the SQL Server you are connecting to. Maybe it's misspelled and or not accessible to the user in the connection.

Prc_ChecIn exists. This piece of code runs fine without issue except that occasionally I get this error – AskaQn Jun 12 '09 at 4:58.

You should always close your sqlconnection immediately after executing the sqlcommand If this is not part of a function, then reinstating it with new is not necessary - just opening it will be sufficient.

The connection is closed immediately afterwards the code snippet just didn't include it. – AskaQn Jun 12 '09 at 5:53.

I forget the connection string option for that but if you invoke the connection string builder it should be on the advanced property grid. Or on www.connectionstrings.com. Also, is this a "user instance" database like when you add a .

Mdf file to a Visual Studio project using SQL Express?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions