This is a discussion on Stored procedure gets executed twice within the ASP and ASP.NET Programming forums, part of the Web Development category; Hello, I call a more complex stored procedure (sproc) from code (asp .net 2.0 website, ExecuteNonQuery()) and it always ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hello, I call a more complex stored procedure (sproc) from code (asp .net 2.0 website, ExecuteNonQuery()) and it always executes twice. I double checked, in debugging mode, if the execute command is fired twice but it isnt. I changed the sproc to a very simple insert statement without transactions etc. and it also gets executed twice. If i am debugging the sproc with visual studio i can see that after the ExecuteNonQuery() it jumps into the sproc executes it and then begins from start. If i exec it manually via query the sproc only runs once. I didnt post the sproc cause it doesnt matter which content it has, always the same behaviour. If you need further information please feel free to ask. Any hints or help would by very appreciated I also asked the question here http://www.discussweb.com/vb-net-pro...ted-twice.html chris |
| Sponsored Links |
| |||
| can u give the code for the executing the stored procedure ....i will check that like SqlConnection cnPubs = new SqlConnection("server=localhost;uid=uid;pwd=pwd;Da tabase=pubs"); SqlCommand cmdAuthors = new SqlCommand("getLatLong", cnPubs); cmdAuthors.CommandType = CommandType.StoredProcedure; cmdAuthors.Parameters.Add("@fdate", SqlDbType.DateTime); cmdAuthors.Parameters["@fdate"].Value = "2007-03-01 19:06:00"; cmdAuthors.Parameters.Add("@tdate", SqlDbType.DateTime); cmdAuthors.Parameters["@tdate"].Value = "2007-03-09 14:23:00"; SqlDataReader drAuthors; cnPubs.Open(); drAuthors = cmdAuthors.ExecuteReader(); while (drAuthors.Read()) { Response.Write(drAuthors.GetValue(0)); Response.Write(drAuthors.GetValue(1)); } Last edited by kingmaker : 10-31-2007 at 02:28 AM. |
| |||
| I use these methods on several points the same way in my project and never had the problem with double execution of one sproc. I also checked the beaviour with sql profiler and can see that the sproc is executed twice in short time. This is the profiler output: exec CheckAvailabilityAndUpdateOrderState @ord_id=68,@ord_ost_id=2 go exec sp_reset_connection go exec CheckAvailabilityAndUpdateOrderState @ord_id=68,@ord_ost_id=2 go exec sp_reset_connection go Code: connectionstring in web.config <add name="TESTDB" connectionString="Server=XXXX\XXXXX;Database=XXX;User Id=XX;Password=XXXX"/> Public Class clsDatabasePrivate Function getConnection() As SqlConnection Dim sConnect As String Dim oConn As SqlConnection sConnect = ConfigurationManager.ConnectionStrings("TESTDB").ToString oConn = New SqlConnection(sConnect) oConn.ConnectionString = sConnect Return oConn End FunctionPublic Function executeSqlCommand(ByRef oCommand As SqlCommand) As SqlDataAdapter oCommand.CommandType = CommandType.StoredProcedure oCommand.Connection = getConnection() oCommand.Connection.Open() oCommand.ExecuteNonQuery() oCommand.Connection.Close() Return New SqlDataAdapter(oCommand) End FunctionEnd Class Public Class clsOrderDim oSqlCmd As SqlCommand Dim oDataAdapter As SqlDataAdapter oSqlCmd = New SqlCommand("CheckAvailabilityAndUpdateOrderState") oSqlCmd.Parameters.AddWithValue("@ord_id", Me.Id) oSqlCmd.Parameters.AddWithValue("@ord_ost_id", Me.OtherId) oDataAdapter = oDb.executeSqlCommand(oSqlCmd) oDataAdapter.Fill(oDataSet, "XYZ")End Class Last edited by chris : 10-31-2007 at 07:47 AM. |
| |||
| great..I am also debugging and trying to resolve the same code in C#.........but u got....it ...ok good work |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| stored procedure | itbarota | Database Support | 3 | 03-10-2008 09:43 PM |
| how to get out parameter of stored procedure ? | Murali | PHP Programming | 0 | 12-16-2007 04:57 AM |
| Stored procedure gets executed twice | chris | VB.NET Programming | 0 | 10-30-2007 08:55 AM |
| difference between stored procedure and functions | smani | Database Support | 5 | 08-26-2007 10:52 PM |
| Can a stored procedure call itself or recursive stored procedure? How many level SP n | H2o | Database Support | 1 | 08-03-2007 10:55 AM |