M
matteo
Hi everybody,
i've a problem with loading a dataset: i need to load entire contents
of various tables into dataset, however i don't know size of this
table. If table size is too big simply i need a timeout exception and
go on. The problem is that when the table is too big, the Fill method
avanza without any timeout. Why? Mehod code is this:
private DataSet LoadDataSet ( int Table, DBtype db, out string
ErrorMsg)
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = null;
string cmd;
string TableName;
ErrorMsg = "";
try
{
// Table name
TableName = GetTableName ( Table );
// Compose Select statement
cmd = "SELECT * FROM " + TableName;
// SqlDataAdapter (GetConnectionString compose the string and set
connet timeout = 10)
adapter = new SqlDataAdapter( cmd, GetConnectionString());
adapter.SelectCommand.
// Ten seconds for the command
adapter.SelectCommand.CommandTimeout = 10;
// And ten seconds for the connection (i think i don't need
because i set before)
adapter.SelectCommand.Connection.Timeout = 10;
//
// Execute
//
adapter.Fill( ds );
return ds;
}
catch ( System.Exception ex )
{
ErrorMsg = ex.ToString();
return null;
}
finally
{ if ( adapter != null ) adapter.Dispose(); }
}
i've a problem with loading a dataset: i need to load entire contents
of various tables into dataset, however i don't know size of this
table. If table size is too big simply i need a timeout exception and
go on. The problem is that when the table is too big, the Fill method
avanza without any timeout. Why? Mehod code is this:
private DataSet LoadDataSet ( int Table, DBtype db, out string
ErrorMsg)
{
DataSet ds = new DataSet();
SqlDataAdapter adapter = null;
string cmd;
string TableName;
ErrorMsg = "";
try
{
// Table name
TableName = GetTableName ( Table );
// Compose Select statement
cmd = "SELECT * FROM " + TableName;
// SqlDataAdapter (GetConnectionString compose the string and set
connet timeout = 10)
adapter = new SqlDataAdapter( cmd, GetConnectionString());
adapter.SelectCommand.
// Ten seconds for the command
adapter.SelectCommand.CommandTimeout = 10;
// And ten seconds for the connection (i think i don't need
because i set before)
adapter.SelectCommand.Connection.Timeout = 10;
//
// Execute
//
adapter.Fill( ds );
return ds;
}
catch ( System.Exception ex )
{
ErrorMsg = ex.ToString();
return null;
}
finally
{ if ( adapter != null ) adapter.Dispose(); }
}