Hello,

In my Global.asax, I have my connection string
Application("strDSNSQL") = "SERVER=(local); UID=LOGIVELO_USER;
PWD=!ItsAll4Me; DATABASE=Logivelo1"

I have thise code in an ASPX page

Dim DecisionCompagnie As Compagnie

Dim dtDecisionCompagnie As DataTable

DecisionCompagnie = New Compagnie()

dtDecisionCompagnie =
DecisionCompagnie.GetLastDecision(Session("compagnie"), Session("Periode"),
Application("strDSNSQL"))

If dtDecisionCompagnie.Rows.Count > 0 Then
txtNomCompagnie.Text = dtDecisionCompagnie.Rows(0).Item(4)
txtNomGroupe.Text = dtDecisionCompagnie.Rows(0).Item(2)
txtPeriode.Text = Session("Periode")
txtEmissionAction.Text = dtDecisionCompagnie.Rows(0).Item(6)
txtEmpruntLongTerme.Text = dtDecisionCompagnie.Rows(0).Item(7)
txtRemboursement.Text = dtDecisionCompagnie.Rows(0).Item(9)
...
This is the function that I call in my Compagnie Class

Public Function GetLastDecision(ByVal pstrId As String, ByVal pintNoPeriode
As Integer, ByVal pstrDSN As String) As DataTable
Dim strCommande As String = ""
Try
strCommande = "SELECT * FROM DecisionCompagnie WHERE NoCompagnie = " &
pstrId & " AND NoPeriode = " & pintNoPeriode
Dim daDataAdapter As New SqlDataAdapter(strCommande, pstrDSN)
Dim dsDataSet As New DataSet()
daDataAdapter.Fill(dsDataSet, "DecisionCompagnie")
Dim dtDataTable As DataTable = dsDataSet.Tables(0)
GetLastDecision = dtDataTable
dtDataTable = Nothing
daDataAdapter = Nothing
Catch...

When I try this code 10 times, 8 times it is ok and 2 times I have a
TimeOut. I have SQLServer 2000 on my computer and I am alone on the
network. I want to understand what I do wrong

Thank you
Marc

Re: Why do I have TimeOut by William

William
Wed Jan 21 10:39:21 CST 2004

Is it a connection timeout or a command timeout? Either way, you can use
Profiler to find out what's going on behind the scenes. Are a lot of people
banging on the server or is this just a test machine? Can you open and
close all the other connections in a realistic amount of time? Is it
consistently 8 and 2 and is there any pattern like always the last two
attempts timeout or is it totally random?



A few general points though (not the problem at hand, but something you may
want to conisder)..particularly if this thing will be running on the web,
I'd highly recommend using Stored Procedures instead of dynamic SQL and at a
minimum use parameters for your select statement:

Strings are immutable, so no real need to set it to "" first, you can just
set it in the assignment.
strCommande = "SELECT * FROM DecisionCompagnie WHERE NoCompagnie =
@NoCompagnie > AND NoPeriode = @NoPeriod"

then, with your command object
myCommand.Parameters.Add("@NoCompagnie", SqlDbType.Varchar).Value = pstrId
myCommand.Parameters.Add("@NoPeriod", SqlDbType.Int).Value =
CType(pintNoPeriode, Integer)
'The actual DB Types should map to the read column types, and there are
other overloads for using parameters, but this is just a basic example.
"Marc Robitaille" <marcmarie@videotron.ca.delete> wrote in message
news:u2#JmgD4DHA.2468@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> In my Global.asax, I have my connection string
> Application("strDSNSQL") = "SERVER=(local); UID=LOGIVELO_USER;
> PWD=!ItsAll4Me; DATABASE=Logivelo1"
>
> I have thise code in an ASPX page
>
> Dim DecisionCompagnie As Compagnie
>
> Dim dtDecisionCompagnie As DataTable
>
> DecisionCompagnie = New Compagnie()
>
> dtDecisionCompagnie =
> DecisionCompagnie.GetLastDecision(Session("compagnie"),
Session("Periode"),
> Application("strDSNSQL"))
>
> If dtDecisionCompagnie.Rows.Count > 0 Then
> txtNomCompagnie.Text = dtDecisionCompagnie.Rows(0).Item(4)
> txtNomGroupe.Text = dtDecisionCompagnie.Rows(0).Item(2)
> txtPeriode.Text = Session("Periode")
> txtEmissionAction.Text = dtDecisionCompagnie.Rows(0).Item(6)
> txtEmpruntLongTerme.Text = dtDecisionCompagnie.Rows(0).Item(7)
> txtRemboursement.Text = dtDecisionCompagnie.Rows(0).Item(9)
> ...
> This is the function that I call in my Compagnie Class
>
> Public Function GetLastDecision(ByVal pstrId As String, ByVal
pintNoPeriode
> As Integer, ByVal pstrDSN As String) As DataTable
> Dim strCommande As String = ""
> Try
> strCommande = "SELECT * FROM DecisionCompagnie WHERE NoCompagnie = " &
> pstrId & " AND NoPeriode = " & pintNoPeriode
> Dim daDataAdapter As New SqlDataAdapter(strCommande, pstrDSN)
> Dim dsDataSet As New DataSet()
> daDataAdapter.Fill(dsDataSet, "DecisionCompagnie")
> Dim dtDataTable As DataTable = dsDataSet.Tables(0)
> GetLastDecision = dtDataTable
> dtDataTable = Nothing
> daDataAdapter = Nothing
> Catch...
>
> When I try this code 10 times, 8 times it is ok and 2 times I have a
> TimeOut. I have SQLServer 2000 on my computer and I am alone on the
> network. I want to understand what I do wrong
>
> Thank you
> Marc
>
>



Re: Why do I have TimeOut by Chris

Chris
Wed Jan 21 11:39:04 CST 2004

You may be running out of SQL connections in the pool.
Instead of setting daDataAdapter to nothing, do a daDataAdapter.Dispose()
(setting the daDataAdapter to nothing does not release the connection).


"Marc Robitaille" <marcmarie@videotron.ca.delete> wrote in message
news:u2%23JmgD4DHA.2468@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> In my Global.asax, I have my connection string
> Application("strDSNSQL") = "SERVER=(local); UID=LOGIVELO_USER;
> PWD=!ItsAll4Me; DATABASE=Logivelo1"
>
> I have thise code in an ASPX page
>
> Dim DecisionCompagnie As Compagnie
>
> Dim dtDecisionCompagnie As DataTable
>
> DecisionCompagnie = New Compagnie()
>
> dtDecisionCompagnie =
> DecisionCompagnie.GetLastDecision(Session("compagnie"),
Session("Periode"),
> Application("strDSNSQL"))
>
> If dtDecisionCompagnie.Rows.Count > 0 Then
> txtNomCompagnie.Text = dtDecisionCompagnie.Rows(0).Item(4)
> txtNomGroupe.Text = dtDecisionCompagnie.Rows(0).Item(2)
> txtPeriode.Text = Session("Periode")
> txtEmissionAction.Text = dtDecisionCompagnie.Rows(0).Item(6)
> txtEmpruntLongTerme.Text = dtDecisionCompagnie.Rows(0).Item(7)
> txtRemboursement.Text = dtDecisionCompagnie.Rows(0).Item(9)
> ...
> This is the function that I call in my Compagnie Class
>
> Public Function GetLastDecision(ByVal pstrId As String, ByVal
pintNoPeriode
> As Integer, ByVal pstrDSN As String) As DataTable
> Dim strCommande As String = ""
> Try
> strCommande = "SELECT * FROM DecisionCompagnie WHERE NoCompagnie = " &
> pstrId & " AND NoPeriode = " & pintNoPeriode
> Dim daDataAdapter As New SqlDataAdapter(strCommande, pstrDSN)
> Dim dsDataSet As New DataSet()
> daDataAdapter.Fill(dsDataSet, "DecisionCompagnie")
> Dim dtDataTable As DataTable = dsDataSet.Tables(0)
> GetLastDecision = dtDataTable
> dtDataTable = Nothing
> daDataAdapter = Nothing
> Catch...
>
> When I try this code 10 times, 8 times it is ok and 2 times I have a
> TimeOut. I have SQLServer 2000 on my computer and I am alone on the
> network. I want to understand what I do wrong
>
> Thank you
> Marc
>
>