strange datagrid issue

Associate
Joined
18 Oct 2002
Posts
972
Location
Derby
Is there any reason why having a more than one datagrid on a page cause weird results? I have a simple page which lists employees in three departments. I have department 1 as userid 1-20 then department 2 as userid 21-30 and have the queries in sql. My code is set out like this:



Code:
void Page_Load()
    {
        GetCommercialServices();
        GetPrivateServices();
    }
   
   
   
    void GetCommercialServices()
    {
       

            OdbcConnection DataConnection = new OdbcConnection(ConnectionString);
            QueryString = "SELECT (([SOLICITOR].[SolicitorID] >= 12) AND ([SOLICITOR].[SolicitorID] <= 22))";

            DataConnection.Open();
            DataCommand.CommandText = QueryString;
            DataCommand.Connection = DataConnection;        

            DataAdapter.SelectCommand = DataCommand;
            DataAdapter.Fill(dataSet);

            GetCommercialClient.DataSource = dataSet;
            GetCommercialClient.DataBind();
           
       
    }

    void GetPrivateServices()
    {
       

            OdbcConnection DataConnection = new OdbcConnection(ConnectionString);
            QueryString = "(([SOLICITOR].[SolicitorID] >= 23) AND ([SOLICITOR].[SolicitorID] <= 25))";


            DataConnection.Open();
            DataCommand.CommandText = QueryString;
            DataCommand.Connection = DataConnection;


            DataAdapter.SelectCommand = DataCommand;
            DataAdapter.Fill(dataSet);

            GetPrivateClient.DataSource = dataSet;
            GetPrivateClient.DataBind();
      
    }



If I just invoke department 1 I get a correct output like so:

Dave Smith
John Smith

If I just invoke department 2 I get a correct output like so:

Kevin Taylor
Steven Taylor

If I invoke both methods I get the first datagrid ok, but the second one is the two datagrids combined. Is there any explanation for this madness?

Note: I have made the sql statments shorter.
 
Back
Top Bottom