?
Solved

SQL produces different results, on a re-start

Posted on 2006-03-23
3
Medium Priority
?
200 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
0
Comment
Question by:ba272
  • 2
3 Comments
 

Author Comment

by:ba272
ID: 16274879
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
 
LVL 8

Accepted Solution

by:
vinhnl earned 2000 total points
ID: 16275578
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
 

Author Comment

by:ba272
ID: 16275662
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question