473,625 Members | 3,210 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 10581
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
1281
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
7546
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
2545
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. Here is the code for data transmission from tableadapter to Access database :
1
4548
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 to generate the data access layer. Describing the TableAdapter wizard, here is a quote from the...
6
10902
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
1733
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
2463
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 loop or so? TIA Henro
0
1481
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 alias = CHANGE The cast on aud_dt and aud_tm are because both are datetime, but the app stores...
0
1711
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 default Insert method to tableadapter it is "double" ? What is
0
8259
marktang
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...
0
8696
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6119
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4090
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...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.