Connection Sql 2005 Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Connection Sql 2005 Problem

    Hello,

    I have create a Client - Server application.

    When execute client1: all it works
    When i execute "client2" while "client1" is running and using the database,
    i receive this error:
    <<There is already an open DataReader associated with this Command >>
    I have resolved This problem with: <MultipleActive ResultSets=true in a
    string connection

    Now i receive another error:
    <<ExecuteRead er requires an open and available Connection. The connection's
    current state is open>>

    I receive error on this command: dataadapter.fil l

    Do you know why?

    Thank you


  • diAb0Lo

    #2
    Re: Connection Sql 2005 Problem

    On 11 mayo, 09:39, "John" <j...@iol.itwro te:
    Hello,
    >
    I have create a Client - Server application.
    >
    When execute client1: all it works
    When i execute "client2" while "client1" is running and using the database,
    i receive this error:
    <<There is already an open DataReader associated with this Command >>
    I have resolved This problem with: <MultipleActive ResultSets=true in a
    string connection
    >
    Now i receive another error:
    <<ExecuteRead er requires an open and available Connection. The connection's
    current state is open>>
    >
    I receive error on this command: dataadapter.fil l
    >
    Do you know why?
    >
    Thank you
    I supposed you are using static object incrusted in your forms. I
    suggest you to use dynamic objects (created by code) to connect to a
    database. You can use OLEDB, SqlClient or ODBC classes.

    Comment

    • John

      #3
      Re: Connection Sql 2005 Problem

      This is my code:

      Public Function GetDataTable(By Val SpName As String, ByVal Parameters() As
      tpDbParameter, ByVal FillSchema As Boolean) As datatable
      Dim mSqlDa As SqlDataAdapter
      Dim mDtable As New Data.DataTable
      Dim i As Short

      'Class for connections
      Dim mDbConnector As New DbConnector
      mSqlConn = mDbConnector.Ge tSQLConnection
      mDbConnector = Nothing

      Dim SqlCmd As New SqlCommand(SpNa me, mSqlConn, mTransaction)
      SqlCmd.Paramete rs.Clear()
      SqlCmd.CommandT ype = CommandType.Sto redProcedure

      For i = 0 To Parameters.Leng th - 1
      SqlCmd.Paramete rs.AddWithValue (Parameters(i). Name,
      Parameters(i).V alue).UdtTypeNa me = Parameters(i).U dtType
      Next

      mSqlDa = New SqlDataAdapter( SqlCmd)

      Try

      If FillSchema Then
      mSqlDa.FillSche ma(mDtable, SchemaType.Sour ce)
      End If
      mSqlDa.Fill(mDt able) <----- Error in this row

      Catch ex As Exception
      msgbox ex.Message & vbCrLf & ex.StackTrace
      Finally
      mSqlDa.Dispose( )
      mSqlDa = Nothing
      SqlCmd.Dispose( )
      SqlCmd = Nothing
      If MustCloseConnec tion Then
      mSqlConn.Close( )
      mSqlConn.Dispos e()
      mSqlConn = Nothing
      End If
      End Try

      Return (mDtable)

      End Function


      Comment

      Working...