473,388 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

C# data question

69
I'm pulling data from an Access database and filling fields on a form in an app that I'm developing using C# in Visual Studio 2005. I'm using the following code (at bottom of post) to clear the data and then get what I want.

Is there any way that when I do this fill I can filter the data based on a variable.

For instance lets say that the query that I'm pulling the data from (the one listed in the code) just pulls all the data and that I want to filter it by just getting the data that has a NumberCode (example table field) of 1.

Any ideas will be greatly appreciated... I'm pretty new to C#.

Expand|Select|Wrap|Line Numbers
  1. qry_ORMClaimInfoTableAdapter.ClearBeforeFill.ToString();
  2. this.qry_ORMClaimInfoTableAdapter.Fill(this.getFTPdataVIEWSDataSet.qry_ORMClaimInfo);
NOTE: those spaces are not in my code... but I can't seem to get them out when entering the code here... very strange.
Jun 28 '07 #1
2 1034
dip_developer
648 Expert 512MB
I'm pulling data from an Access database and filling fields on a form in an app that I'm developing using C# in Visual Studio 2005. I'm using the following code (at bottom of post) to clear the data and then get what I want.

Is there any way that when I do this fill I can filter the data based on a variable.

For instance lets say that the query that I'm pulling the data from (the one listed in the code) just pulls all the data and that I want to filter it by just getting the data that has a NumberCode (example table field) of 1.

Any ideas will be greatly appreciated... I'm pretty new to C#.

Expand|Select|Wrap|Line Numbers
  1. qry_ORMClaimInfoTableAdapter.ClearBeforeFill.ToString();
  2. this.qry_ORMClaimInfoTableAdapter.Fill(this.getFTPdataVIEWSDataSet.qry_ORMClaimInfo);
NOTE: those spaces are not in my code... but I can't seem to get them out when entering the code here... very strange.

In my opinion just create a Dataview from table of your dataset....dataview can be Filtered according to your criteria.
Following is the sample code to filter a dataview.You can then bind your dataview with any control like Datagrid or Gridview or ListView.

Expand|Select|Wrap|Line Numbers
  1.  
  2.          DataView dv = new DataView(myDataset.Tables("myTable"));
  3.         dv.RowFilter = "NumberCode = 1";
  4.        Datagrid1.DataSource = dv;
  5.  
Jun 29 '07 #2
narpet
69
In my opinion just create a Dataview from table of your dataset....dataview can be Filtered according to your criteria.
Following is the sample code to filter a dataview.You can then bind your dataview with any control like Datagrid or Gridview or ListView.

Expand|Select|Wrap|Line Numbers
  1.  
  2.          DataView dv = new DataView(myDataset.Tables("myTable"));
  3.         dv.RowFilter = "NumberCode = 1";
  4.        Datagrid1.DataSource = dv;
  5.  
Thanks very much. I actually got the sort to work. It's based on a field on the form (we'll call it ID). The field has a variable name (we'll call it vID). When I do my filter I essentially do what you stated: "dv.RowFilter = "tableID = " + vID.Text;

This works the first time, grabbing the value of vID which is in the ID field on the form. But if I change the value in ID to something else it doesn't update and I still get the first sort.

How do I update the variable to insure that I get the proper value?

Any more help will be greatly appreciated.
Jun 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
1
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
5
by: Rick | last post by:
The data adapter wizard allows you to add more than one table, but that doesn't seem to work right when setting up a dataset. Some of the documentation I have read states that only one table...
15
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
11
by: E.T. Grey | last post by:
Hi, I have an interesting problem. I have a (LARGE) set of historical data that I want to keep on a central server, as several separate files. I want a client process to be able to request the...
5
by: AAJ | last post by:
Hi all FIRST THE BORING BITS....... I normally use a Database layer, a Business layer and a GUI layer. The GUI uses an Object data source to bind to the Business layer which in turn binds...
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
1
by: cypher_key | last post by:
I want to write a simple application for my own use. I've already have the data populated in a database and I have a data source setup. I can use the wizards to generate a master detail data form...
1
by: student2008 | last post by:
Sorry about the title its a tricky one. I have a form which allows me to add a question and answers into a mysql database via a combination of, if a certain option is chosen and the reset button...
0
by: saijin | last post by:
I'm planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything Here's the ActionScript 3.0 import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.