473,554 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How Do I change the where clause of the TableAdapter

Hi,

in the old days, pre .Net 2.0 I could just modify the SQLCommand of the
SQlDataAdapter to reflect a different where clause and then issue a .Fill(),
and Whamo!!! everything worked.. How am I to accomplish the same task using
..NET 2.0 and the NEW "TableAdapt er", I can't see myself creating 100's of
Queries using the wizard, is there anyway for me to just change the sql
Where clause at runtime? I have the TableAdapter bound to a DataGrid, and
am aware that there is a filter property, but I don't think setting this
filter property forces a reread from the database, and my my database
contains 100,000's of records.

any help would be very much appreciated..

thanks,
Feb 18 '06 #1
2 10575
hi,

"Rob Dob" <ro************ @yahoo.com> wrote in message
news:OX******** *****@TK2MSFTNG P15.phx.gbl...
Hi,

in the old days, pre .Net 2.0 I could just modify the SQLCommand of the
SQlDataAdapter to reflect a different where clause and then issue a
.Fill(), and Whamo!!! everything worked.. How am I to accomplish the same
task using .NET 2.0 and the NEW "TableAdapt er", I can't see myself
creating 100's of Queries using the wizard, is there anyway for me to
just change the sql Where clause at runtime? I have the TableAdapter
bound to a DataGrid, and am aware that there is a filter property, but I
don't think setting this filter property forces a reread from the
database, and my my database contains 100,000's of records.

Since TableAdapters are partial classes you could extend them by adding
another partial class, eg:

SomeDataSet.cs
------------------

using System.Data.Sql Client;

namespace SomeWindowsAppl ication
{
namespace SomeDataSetTabl eAdapters
{
partial class SomeTableAdapte r
{
public int FillBySelect(So meDataSet.SomeD ataTable Table, string
Select)
{
this.Adapter.Se lectCommand = new SqlCommand(Sele ct,
this.Connection );
if (this.ClearBefo reFill)
Table.Clear();

return this.Adapter.Fi ll(Table);
}
}
}
}

(You offcourse have to replace "Some" with the actual names you have and if
you prefer you can easily make it a "FillByWher e" instead.)

HTH,
Greetings

any help would be very much appreciated..

thanks,

Feb 19 '06 #2
Hi,

Thanks, that worked like a Champ!!!
Mar 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1277
by: dmkeith2 | last post by:
I plan to add a PrintMe column (Yes/No) to my main table so that only certain records will be printed. How do I change the values back to No when I close the form which is based on a query based on the table. Thanks for your help.
5
7540
by: Programatix | last post by:
Hi, Have anyone ever benchmark the TableAdapter performance compared to DataTable's Load method? I found out that the DataTable's Load method is about 10x faster than TableAdapter's Fill method. I used the same SELECT query and DataSet (predefined), for both test. For the DataTable's Load method, we first need to create a DataReader.
15
2533
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions, modifications and deletions functions very well in the dataset. But impossible to transmit modifications in ACCESS database. Impossible to WRITE in database....
1
4536
by: Demetri | last post by:
I have a question / concern regarding the new suggested way of creating a data access layer in an n-tier application. Typically, a web application specifically, using the SOA (Service Oriented Architecture) approach. At various sites such as 15 Seconds (http://www.15seconds.com/issue/050721.htm) they advocate using the TableAdapter wizard...
6
10897
by: Altman | last post by:
I am playing around with making a dataset with the designer in vb.net 2005. I realize you can add parameters to select statement and then filter off of those parameters. What I would like to do is to take the dataset that the designer made and add the whole where clause to it at run time. Is this possible?
2
1727
by: paolol | last post by:
Hi, I have a dataset with few tableAdapter and I wish to change the connection string by user imput, the only way I found to do that is using each tableadapter, but in this way I have change one by one. Any one know a faster way ? Thanks, PaoloL.
3
2459
by: Henrootje | last post by:
I have a lot of tables that hold a lot of numeric fields. The names of all of these tables start with ' tblRO' Now it turns out that all of the numeric fields with type double precision have the property 'schaal' (<- dutch, the one above 'precision' ) set to zero. This should be '10' . Is there a way to change this through VBA? Using a...
0
1477
by: rdraider | last post by:
I have an audit table that tracks changes to inventory items. I am trying to find the first change in avg_cost per item. The table will contain 1 row for the before record and another row for the changed to record. The table tracks everything change to items, not just avg_cost. 'B' in where clause and alias = BEFORE 'C' in where clause and...
0
1704
by: Yin99 | last post by:
I'm using TableAdapter with .NET 2.0 and SQL 2005. In SQL Database, a column's type is "float". Default TableAdapter methods update, insert, get, etc. maps this automatically to c# type "double" Question- Why is it when I create a new SQL Query, Insert Method, all of a sudden the tableadapter is calling the variable "float" when the...
0
7499
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8013
jinu1996
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...
1
7531
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...
0
7862
tracyyun
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...
1
5414
isladogs
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...
0
3539
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...
0
3530
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1994
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.