SQL produces different results, on a re-start

Hi,

I have an SQL query which works fine when I start my program, and my close scrutiny tells me it's okay.  But when the program's allowed to run, it misses new orders, but on a subsequent restart, my program finds them.  Could I be doing something wrong with the connection?

Any ideas?  

if ( sqlDataAdapter == null || dataSet == null )
{
   pulseOrderHistory = new PulseOrderHistory( Handles, connectString );
   sqlDataAdapter = new SqlDataAdapter( sql, connectString );
   dataSet = new DataSet();
   sqlDataAdapter.Fill(dataSet, "Orders");
}                              
else
{
   dataSet.Clear();
   sqlDataAdapter.Fill( dataSet, "Orders" );
}


Thanks,
Bob
ba272Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ba272Author Commented:
Here's the SQL...



SELECT Orders.Order_Number, Orders.Actual_Order_Date,Orders.Order_Saved, Orders.Order_Type_Code,Orders.Customer_Name, Customer.Street_Number, Streets.Street_Name, City.City_Name,Orders.Order_Status_Code, Orders.OrderRevNbr, Orders.Route_Time, Orders.Return_Time, Orders.Driver_ID, 'false' AS Wings FROM Orders, Customer, Streets, City

WHERE (Orders.Order_Type_Code='C' OR Orders.Order_Type_Code='D') AND ((Orders.Order_Status_Code IN (1,2,3,199) AND Orders.Order_Saved <= {ts '2006-03-23 16:35:32'}) OR (Orders.Order_Status_Code=4 AND Return_Time > {ts '2006-03-23 16:34:32'}) OR (Orders.Order_Status_Code=99 AND Order_Saved > {ts '2006-03-23 14:35:32'}) OR (Orders.Order_Status_Code=100 AND Order_Saved > {ts '2006-03-23 14:35:32'})) AND Orders.Customer_Code=Customer.Customer_Code AND Customer.Street_Code=Streets.Street_Code AND Streets.City_Code=City.City_Code
vinhnlCommented:
Hi Ba272 ,

The line 'if ( sqlDataAdapter == null || dataSet == null )' has a problem. If before, you declare 2 lines :

SqlDataAdapter sqlDataAdapter == null;
Dataset dataSet == null;

it's OK, but if you only declare :

SqlDataAdapter sqlDataAdapter;
Dataset dataSet;

you will meet this problem.

The problem that in second case, atfer daclare that, the compiler doesn't ensure that sqlDataAdapter = null et dataSet = null.

Good luck,
VINHNL

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ba272Author Commented:
VINHNL,

I actually had this:

SqlDataAdapter sqlDataAdapter == null;
Dataset dataSet;

which was working fine,  although it was sloppy.  I changed it to :

SqlDataAdapter sqlDataAdapter == null;
Dataset dataSet == null;


Thanks,
Bob
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.