none
How to pass parameter value to a dataset programmatically (VB/ASP/VS2008)

    Question

  •  

    SQL Statement generating the dataset output requires a parameter. How can I pass the value to it from within Visual Basic(VS2008)? The dataset is used to produce the input for a local Sql Server Report. For example, put code in the Load Event of the ASP page containing the ReportViewer.
    Thursday, January 31, 2008 2:59 PM

All replies

  • this is a bit of a broad subject, the concepts behind accessing data in a database from a webform or winform is a subject of books.  I recommend you do some searches on ADO.Net

    Thursday, January 31, 2008 9:03 PM
  • You are correct. But I am not trying to build a car, just want to drive it.

    1- I have a dataset with a SQL query statement that has a single parameter. That is simple.

    2- The dataset (and associated table adapter) are used in a local SQL Server report

    3- The report is published using a web form and a Microsoft Report Viewer control 

    2- Somewhere in the VB code of the Report Viewer I should be able to set the value of the parameter based on program logic. It appears that the data set (and associated components, i.e. tableadapter) are in a different dimension than the rest of the web forms in the project and there is no way of sharing information, for example using the session-state variables. All I want to do is  i.e.:

    Me._EmployeeTableAdapter.GetData(parm_a)

    where parm_a is a vlaue generated inside the VB code.

     

    Thursday, January 31, 2008 10:53 PM
  • Well, to try to point you in a possible right direction

     

    You need to use an objectdatasource, hand it the table adapater, and the object datasource will realize the table adapter requires a parameter, so it will want to know where to get that parameter from, and you'd point it to a textbox, or dropdown or whatever.

     

    That's a really brief synopsis that hopefully helps you out, and almost all of it can be done from a design window without writing any code so long as you've deployed all needed objects to your webform already

    Friday, February 01, 2008 6:08 PM
  • Thanks for the help. After much "exploration", including writing a class to create and pass back the DataAdapter, I took your suggestion and did it through the ObjectDataSource. It seems to be working fine.

    Monday, February 04, 2008 5:28 PM