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?
 
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
0
 
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
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.