-3

this is my code in the dataset.cs. what do I have to add for set the timeout in the connection and the command?

namespace M_Report
{


    partial class A_DBDataSet
    {

        partial class VP_DataTable
        {
        }
    }
}


namespace M_Report.A_DBDataSetTableAdapters
{
    partial class VD_TableAdapter
    {
    }

    public partial class VP_rofitsTableAdapter {
    }
}
Liam
  • 27,717
  • 28
  • 128
  • 190
  • 1
    I have literally no idea what you asking – Liam May 02 '19 at 10:23
  • I'm guessing by the fact that you accepted an answer that your reffering to ado.net `SqlCommand` object. Please try and be more clear in your questions – Liam May 02 '19 at 13:28
  • 1
    thanks! I find some codeto add in the dataset.cs. –  May 04 '19 at 19:11

2 Answers2

0

If you want a timeout for a particular query, then CommandTimeout is the way.

command.CommandTimeout = 60; //default is 30 seconds.

Or you can also add it in the connection string

connect timeout=180;
Hitesh Anshani
  • 1,499
  • 9
  • 19
0

Add this code in the DataSet.cs:

namespace P.A_DBDataSetTableAdapters
{
    public partial class VD_TableAdapter
    {
        public int CommandTimeout
        {
            set
            {
                int i = 0;
                while ((i < this.CommandCollection.Length))
                {
                    if ((this.CommandCollection[i] != null))
                        this.CommandCollection[i].CommandTimeout = value;
                    i = (i + 1);
                }
            }
        }
    }
}

And this code in the Form.cs: this.vD_TableAdapter.CommandTimeout = 1800;