Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Multiple connection problem

Multiple connection problem

Scheduled Pinned Locked Moved Database
helpdatabasexml
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hzi
    wrote on last edited by
    #1

    I've an strange case where a second connection to a Sqlserver database hangs until time out has expired, the schema is below: Connection1=New connection(database1) Connection1.Open Connection1.Begintrans ... Connection2=New connection(database1) Connection2.Open Command2.Connection=Connection2 Command2.ExecuteSelectionSQL **|-----------------------here it hangs** Connection2.Close ....... Connection1.Commit Connection1.Close The first connection remains opened and in transaction while connection2 is opened with the same querystring, it opens correctly but when I issue a command using connection2 it hangs. I use System.Data.SqlClient and I've tried different options in querystring (Enlist=false,.....) but I cannot solve the problem. Thanks for your help, :) Hzi.

    A 1 Reply Last reply
    0
    • H Hzi

      I've an strange case where a second connection to a Sqlserver database hangs until time out has expired, the schema is below: Connection1=New connection(database1) Connection1.Open Connection1.Begintrans ... Connection2=New connection(database1) Connection2.Open Command2.Connection=Connection2 Command2.ExecuteSelectionSQL **|-----------------------here it hangs** Connection2.Close ....... Connection1.Commit Connection1.Close The first connection remains opened and in transaction while connection2 is opened with the same querystring, it opens correctly but when I issue a command using connection2 it hangs. I use System.Data.SqlClient and I've tried different options in querystring (Enlist=false,.....) but I cannot solve the problem. Thanks for your help, :) Hzi.

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      seems like you have locking problems .. do you access the same tables ? in both connections ?

      H 1 Reply Last reply
      0
      • A Anonymous

        seems like you have locking problems .. do you access the same tables ? in both connections ?

        H Offline
        H Offline
        Hzi
        wrote on last edited by
        #3

        Yes, when I'm accessing the same table, it hangs, but when I access another table it not hangs, but SQLServer locks a whole table when I insert a single record ?. Thanks

        H 1 Reply Last reply
        0
        • H Hzi

          Yes, when I'm accessing the same table, it hangs, but when I access another table it not hangs, but SQLServer locks a whole table when I insert a single record ?. Thanks

          H Offline
          H Offline
          Hesham Amin
          wrote on last edited by
          #4

          No.. locking is not this simple..it differs according to how you access the table.. tell me the query so i can help !!

          H 1 Reply Last reply
          0
          • H Hesham Amin

            No.. locking is not this simple..it differs according to how you access the table.. tell me the query so i can help !!

            H Offline
            H Offline
            Hzi
            wrote on last edited by
            #5

            Here is a trace of the steps shown in sqltrace tool: **with the first connection** exec sp_reset_connection SET TRANSACTION ISOLATION LEVEL READ COMMITTED;BEGIN TRANSACTION sp_reset_connection update objectes set [Caducitat]=NULL, [DataValid]=NULL, [UltimaMod]=CONVERT(DATETIME, '2003-01-16T13:18:00', 126) where id=100225 **with the second connection** sp_reset_connection select * from objectes where idref=''BAINtiA000046'' and IM1=1' **<-------------It hangs here** It's all. Thanks.

            P 1 Reply Last reply
            0
            • H Hzi

              Here is a trace of the steps shown in sqltrace tool: **with the first connection** exec sp_reset_connection SET TRANSACTION ISOLATION LEVEL READ COMMITTED;BEGIN TRANSACTION sp_reset_connection update objectes set [Caducitat]=NULL, [DataValid]=NULL, [UltimaMod]=CONVERT(DATETIME, '2003-01-16T13:18:00', 126) where id=100225 **with the second connection** sp_reset_connection select * from objectes where idref=''BAINtiA000046'' and IM1=1' **<-------------It hangs here** It's all. Thanks.

              P Offline
              P Offline
              pushpi
              wrote on last edited by
              #6

              either make ur query serialised or change lock type P.S. PATWAL

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups