Connection Sql 2005 Problem

J

John

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: <MultipleActiveResultSets=true> in a
string connection

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

I receive error on this command: dataadapter.fill

Do you know why?

Thank you
 
D

diAb0Lo

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: <MultipleActiveResultSets=true> in a
string connection

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

I receive error on this command: dataadapter.fill

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.
 
J

John

This is my code:

Public Function GetDataTable(ByVal 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.GetSQLConnection
mDbConnector = Nothing

Dim SqlCmd As New SqlCommand(SpName, mSqlConn, mTransaction)
SqlCmd.Parameters.Clear()
SqlCmd.CommandType = CommandType.StoredProcedure

For i = 0 To Parameters.Length - 1
SqlCmd.Parameters.AddWithValue(Parameters(i).Name,
Parameters(i).Value).UdtTypeName = Parameters(i).UdtType
Next

mSqlDa = New SqlDataAdapter(SqlCmd)

Try

If FillSchema Then
mSqlDa.FillSchema(mDtable, SchemaType.Source)
End If
mSqlDa.Fill(mDtable) <----- Error in this row

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

Return (mDtable)

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top