We help IT Professionals succeed at work.

SQL produces different results, on a re-start

ba272
ba272 asked
on
Medium Priority
224 Views
Last Modified: 2012-05-05
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
Comment
Watch Question

Author

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
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.