Hi,
I'm having some trouble with the following piece of code: - string getAllNew = "SELECT * FROM dbo.HeaderAndDetail WHERE ProcessedToCsv = 0";
-
conn.Open();
-
-
try
-
{
-
SqlCommand cmd = new SqlCommand(getAllNew, conn);
-
SqlDataAdapter dAdapter = new SqlDataAdapter();
-
-
dAdapter.SelectCommand = cmd;
-
DataTable dTable = new DataTable();
-
dAdapter.Fill(dTable);
-
-
cmd.Dispose();
-
cmd = null;
-
-
WriteToCSV(dTable, filename);
-
-
dAdapter.Dispose();
-
dAdapter = null;
-
dTable.Dispose();
-
dTable = null;
-
}
-
catch (Exception ex)
-
{
-
throw new Exception(ex.ToString(), ex);
-
}
-
finally
-
{
-
conn.Close();
-
}
The problem is that after the data table is filled, the rows in it include results that have ProcessedToCsv = 1 (not 0).
When I run the query (SELECT * FROM dbo.HeaderAndDe tail WHERE ProcessedToCsv = 0) in SQL server, it returns accurate results.
When that same query is the data adapter's select command, it returns everything.
What am I doing wrong? I've tried altering the query in code to the following:
SELECT * FROM dbo.HeaderAndDe tail WHERE ProcessedToCsv = @PTC (then adding a parameter and giving it a value before setting the select command of the data adapter)
SELECT * FROM dbo.HeaderAndDe tail WHERE ProcessedToCsv = 'False'
The above did not work.
FYI, "dbo.HeaderAndD etail" is a VIEW in my database. "ProcessedToCsv " is a BIT type column in my Detail TABLE. Playing around with those elements in SQL server is fine. Any query I execute returns accurate results.
I see no errors when I run the above code, or execute various queries in SQL server.
Would appreciate any help with this
1 6389 GaryTexmo 1,501
Recognized Expert Top Contributor
I'm wondering if your code is off... your data adapter doesn't get instantiated with the connection, you instead attach a command to it. I'm not sure if this is right... maybe it is, maybe it isn't (I don't have an SQL database to test with). Perhaps try this... - ...
-
SqlDataAdapter dAdapter = new SqlDataAdapter(getAllNew, conn);
-
dAdapter.Fill(dTable);
-
...
The only other thing I can think of is maybe try using the fully qualified field name. That's kinda a shot in the dark, but maybe there's something funny? - string getAllNew = "SELECT * FROM dbo.HeaderAndDetail WHERE dbo.HeaderAndDetail.ProcessedToCsv = 0";
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: yawnmoth |
last post by:
i'm using an entry in an sql database as a semaphore and it,
unfortunately, doesn't appear to be working. the script that spawns
the child processes has a for loop that performs the same basic sql
query over and over again until the value has changed (there's a one
second delay between each query). unfortunately, the resultant row is
always the same, even when the other process *has* changed it. as an
example, if the orig. value was of...
|
by: Rowland Hills |
last post by:
I have a table which is returning inconsistent results when I query
it!
In query analyzer:
If I do "SELECT * FROM TABLE_NAME" I get no rows returned.
If I do "SELECT COL1, COL2 FROM TABLE_NAME" I get 4 rows returned.
In Enterprise manager:
|
by: Dr John Stockton |
last post by:
What are the best ways of returning multiple results from a subroutine ?
I've been using
... return }
which is inelegant.
I'm used to Pascal's
procedure X(const A, B : integer; var C, D : byte) ;
where A, B are inputs only, and C, D are in/out.
|
by: msnews.microsoft.com |
last post by:
Hi All,
When I use a SQL Query to Fill the Dataset if I use the following Where
Clause
( > '100' )
Then I am getting a 'Data Type Mismatch Error' because the Field Type is
double.
|
by: Earl T |
last post by:
When I try to get the netscape version for version 7, I get the
HttpBrowserCapabilities class returning the version as 5 and not 7.
(see code and output below)
CODE
HttpBrowserCapabilities bc;
string s;
bc = Request.Browser;
....
| |
by: Brian Mitchell |
last post by:
I'm sure this is a very dumb question but when a user clicks on a row in my
data table (which has been sorted) how do I return the correct row index for
my underlying data table? The CurrentRowIndex property gives me the selected
row of the data grid which no longer matches the data table when the columns
have been resorted.
Thanks!!!
|
by: lcottrell |
last post by:
I'll start off by saying I'm not very experienced in writing SQL commands. I am familiar with vbscript though, and I can do a similar thing in that, but can't seem to get it to work in SQL.
What I need is to use Excel to connect to an SQL database and pull down information periodically, which I've been able to mostly do successfully. The problem now is that the information in some of the fields has extra information that makes it hard to read...
|
by: thepresidentis |
last post by:
here is my problem,
i have a website that compiles concert listings for users to search for shows in their local area, i ran into a problem with returning search results due to an improper format of my query, So i formatted the query properly Thanks to steve Klein :) , and all worked fine because there was only 1 show in my data base,
I tryed to search for the show and it returned properly, and then i searched for the show with a different...
|
by: jfarthing |
last post by:
Hi everyone,
I am using a PERL script and am having some probs with it....
$query = sprintf (
"SELECT `Cats`.`Name`,`Address`.`Address`,`Address`.`City`,`Contact`.`Phone`
FROM
(
`Cats`
LEFT JOIN
`Address`
|
by: seegoon |
last post by:
Hi guys.
I'm trying to write some php so that, depending on the page displayed, a certain <div> will load a certain class, giving it a certain background image. I have it down in theory, but there's a problem. My current code is returning multiple results as true, leading to the user receiving source like:
<div id="wrap" class="flower-1flower-2">
In this instance, it is obviously supposed to be either class="flower-1" or class="flower-2"....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |