Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have stumbled upon something that says you can subclass a TableAdapter to change the SQL at runtime. Can someone elaborate on this strategy?

  • #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,776
    Thanks
    41
    Thanked 196 Times in 195 Posts
    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

  • #4
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •