Add more queries to a tableadapter

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
jebus_jt
Posts: 9
Joined: Thu 03 Dec 2009 20:37

Add more queries to a tableadapter

Post by jebus_jt » Wed 09 Dec 2009 18:31

Is there anyway to add more queries to a tableadapter? for example I need a query that returns a table as a result of a select statement that has parameters, but in the same tableadapter I need a query (other select statement) that counts how many rows are in the table...Of course I know how the select statements are going to be, but I don't know if there is a way to add another query.

thanks

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 10 Dec 2009 16:32

Unfortunately, the design-time support of multiple queries for TableAdapter is not available now. We will consider the possibility of adding such functionality in one of the future dotConnect for PostgreSQL versions.

At the moment you can add more queries e.g. to the custom DataTable class. Thus, if you've generated a custom DataSet class CustomDataSet and corresponding DataTable class CustomDataSet.CustomDataTable, it will be something like

Code: Select all

using Devart.Data.PostgreSql;

namespace YourApplicationNamespace
{
    public partial class CustomDataSet
    {
        public partial class CustomDataTable
        {
            public decimal getCount()
            {
                PgSqlCommand command = new PgSqlCommand(
                    "select count(*) from Your_Table", Connection);

                try
                {
                    if (Connection.State !=System.Data.ConnectionState.Open) 
                        Connection.Open();
                    object ret = command.ExecuteScalar();                    
                    return (decimal)ret;
                }
                catch
                {
                    return -1;
                }
                finally
                {
                    Connection.Close();                  
                }                
            }
        }
    }
}

jebus_jt
Posts: 9
Joined: Thu 03 Dec 2009 20:37

Post by jebus_jt » Thu 10 Dec 2009 16:42

ok thanks.
well I've been trying some ways to do that, and I found a solution, maybe it is not the best way to do it but works. What I did was just open the dataset that I created with the Dataset Wizard and I just added a new query in the tableadapter using .NET Wizard for adding queries, and it worked great.

And since I found that way to add queries, I just edit the Designer.VB file adding the extra queries I need, it works fine but anyway its a time eater solution, it will be great if you could add this feature.

Post Reply