I need Help with System.Data.sqlClient

  • Thread starter Thread starter Marc Robitaille
  • Start date Start date
M

Marc Robitaille

Hello,

In my projet, there are class for each table of my database.So, if I want to
get, add, change or delete some thing in a table, I use the class that
correpond to it. I have this kind of code in all class. Usually, it has
allways work fine for all the projects that I have done. I don't know why,
but with a particular project, I have a lot of trouble. The code allways
jam on the DataAdapter Fill Line. Something, my web application is
incredibly fast, but sometime I can wait up to two minutes before the
execution of the Fill line finish and gets to the next statement. Do I miss
something in the configuration of my web application or maybe it is my SQL
Server that have a problem. I work on a computer that it is not connect to
a network so I am the only one who connect to the SQL Server.


Public Function GetTotalAvoir(ByVal pstrId As String, ByVal pstrNoPeriode As
String, ByVal pstrDSN As String)
Dim strCommande As String = ""

Try
strCommande = "SELECT TotalAvoir FROM Bilan WHERE NoCompagnie = " &
pstrId & " AND NoPeriode = " & pstrNoPeriode

Dim daDataAdapter As New SqlDataAdapter(strCommande, pstrDSN)
Dim dsDataSet As New DataSet()

daDataAdapter.Fill(dsDataSet, "Bilan")<-----------This is the line
with witch I have a lot of trouble

Dim dtDataTable As DataTable = dsDataSet.Tables(0)

If dtDataTable.Rows.Count > 0 Then
GetTotalAvoir = dtDataTable.Rows(0).Item(0)
Else
GetTotalAvoir = DBNull.Value
End If

dtDataTable = Nothing
daDataAdapter.Dispose()

Catch

Finally

End Try
End Function

Thank you
Marc
 
Marc: I replied to your last question, but when you step through it, what
is happening, a connection timeout or a command timeout? The fact that you
are the only one hitting the db would lead me to think it's not a connection
timeout, but since the query works fine most of the time (I think you said 8
out of 10 times previously) I think you are going to have to use the old
process of elimination to figure it out. I also mentioned using SQL
Server's Profile and verifying the connection as well as finding out the
exact SQL statement being executed etc. Is it the exact same SQL Statement
for each fill?(Just want to make sure it's an apples to apples comparison).
Also, check the sql statement and fire it in QA and make sure that it runs
correctly there.....
 
Back
Top