Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-24-2012, 04:32 PM   PM User | #1
karlhungus
New to the CF scene

 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
karlhungus is an unknown quantity at this point
Pass variable between windows form and DataSet TableAdapter SQL where clause

In Visual Studio 2010, I have a windows forms application frmMain.cs with a ComboBox. From the form itself I can access its value with cmbxYear.SelectedValue. I also have a DataSet.xsd file to bind to an rdlc report to a TableAdapter to present view data. The TableAdapter has a SelectCommand that takes SQL code. I need to get the value of cmbxYear.SelectedValue into the WHERE clause of the TableAdapter.
Does anyone know how I can access/pass the variable value from the form into the DataSet TableAdapter SelectCommand WHERE clause?
(I am open to other ideas of how to filter an rdlc report with a variable defined on the windows form.)

Last edited by karlhungus; 02-24-2012 at 05:04 PM..
karlhungus is offline   Reply With Quote
Old 02-24-2012, 07:05 PM   PM User | #2
karlhungus
New to the CF scene

 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
karlhungus is an unknown quantity at this point
I have stumbled upon something that says you can subclass a TableAdapter to change the SQL at runtime. Can someone elaborate on this strategy?
karlhungus is offline   Reply With Quote
Old 02-26-2012, 09:39 PM   PM User | #3
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
Call me ignorant- but I have no clue what a TableAdapter is (have never used it)... I researching "what" it is (was looking for it's class lib) I found the MSDN overview and it seems as though it is some object GUI wizard thing....

If you are truly making and aspx page (or hell even a windows form- or for that matter anything utilizing the .net framework) why not use
the SqlDataAdapter class
and the DataSet class? I think your life would be easier... the DataSet class has methods for reading/writing both xml and xsd
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE
alykins is offline   Reply With Quote
Old 02-27-2012, 01:28 PM   PM User | #4
karlhungus
New to the CF scene

 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
karlhungus is an unknown quantity at this point
Smile Solution

I am using the OleDb provider for Oracle.
The bind variable should be a question mark ? not :DEPTCODE

The bind variable :DEPTCODE would be valid for System.Data.OracleClient

See full walk through here: http://www.fullstackbusinessdesign.c...ORA-01008.html

Many thanks to Prashant Kumar for this solution.
http://forums.asp.net/members/Prashant%20Kumar.aspx
karlhungus is offline   Reply With Quote
Reply

Bookmarks

Tags
asp.net, dataset, sql, visual studio 2010, winforms

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:56 AM.


Advertisement
Log in to turn off these ads.