0

I'm turning an SQL Request in my application which is very big and need a lot of traitement. When I execute the request in SQL server, it takes time, but I have the result, but when I execute it in my application, after many seconds, it gives me an error of Time out Expiration.

Here is my VB.Net Button:

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
    Dim str As String = "Data Source=----;Initial Catalog=----;Persist Security Info=True;User ID=---;Password=---"
    Dim con As New SqlConnection(str)
    Dim com As String = " ma Requête"
    Dim Adpt As New SqlDataAdapter(com, con)
    Dim ds As New DataSet()
    Adpt.Fill(ds, "Organisation")
    DataGridView1.DataSource = ds.Tables(0)
End Sub

Can anyone help?

Pang
  • 9,564
  • 146
  • 81
  • 122
  • Try to play with `com.CommandTimeOut`. – muffi Sep 15 '17 at 08:19
  • when I put it like this `com.CommandTimeOut=600` it's error CommandTime out is not a member of String –  Sep 15 '17 at 08:28
  • Very strange, here `com.CommandTimeout = 600` works perfecty fine. – muffi Sep 15 '17 at 08:32
  • I think it's because The com is declared String ?? –  Sep 15 '17 at 08:34
  • When someone gives you a keyword, use it. What did you discover when you searched for "vb.net commandtimeout" in Google? – jmcilhinney Sep 15 '17 at 08:43
  • Why don't you declare com as SqlCommand? If you use it this uncommon way. you will have to do: `Adpt.SelectCommand.CommandTimeout = 600` before filling your DataSet. – muffi Sep 15 '17 at 08:46
  • I find the same thing declaring it like `com.CommandTimeout =600` it's gavin error CommandTime out is not member of String and another declaration int the Connection String `Connect timeout=600` but nothing change –  Sep 15 '17 at 08:47
  • `Adpt.SelectCommand.CommandTimeout = 600` it's Working thank you very much muffi –  Sep 15 '17 at 08:51

0 Answers0