Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multiple values in a querystring

Multiple values in a querystring

Scheduled Pinned Locked Moved C#
databasesharepointdesigndata-structureshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ferronrsmith
    wrote on last edited by
    #1

    I am a noob working a webpage, i wanna pass multiple values from a select box in a query string so that a report may be generated any one can help me please. So basically, if the user enters only one value, only 1 report is queried if they entered more than 1 then more than one report is generated one after another. this is the code i already have, it only make one query to the database now. I want the reports to be created one below the other.... and so on.

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace SealRegister
    {
    public partial class _Default : System.Web.UI.Page
    {

        protected void Page\_Load(object sender, EventArgs e)
        {
            try
            {
                string connstring = @"Data Source=FGVMDEVSVR;Initial Catalog=FGBInvestment;uid=sa;pwd=Wizard1;";
                //string connstring = @"Data Source=FGBMIS01\\SQLEX;Database=FGBInvestments;Trusted\_Connection=yes;User Id;Password=";
                SqlConnection conn = new SqlConnection(connstring);
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "sp\_getTransfer";
    
                //create parameters to provide the input
                SqlParameter parInput1 = cmd.Parameters.Add("@TRANSFER\_ID", SqlDbType.Int);
                parInput1.Direction = ParameterDirection.Input;
                parInput1.Value =  Request.QueryString\["TRANSFER\_ID"\];
    
    
                //execute stored procedure
                conn.Open();
    
                SqlDataReader dtaReader;
                dtaReader = cmd.ExecuteReader();
                while (dtaReader.Read())
                {
                    //Associate service fields names and types from database to elements in smsValues array
                     lblIMID.Text = Convert.ToString(dtaReader\["IMID"\]);
                     lblDESCRIPTION.Text = Convert.ToString(dtaReader\["DESCRIPTION"\]);
                     lblAMOUNT.Text = Convert.ToString(dtaReader\["AMOUNT"\]);
                     lblAMOUNT\_TRANSFER.Text = Convert.ToString(dtaReader\["AMOUNT\_TRANSFER"\]);
                     lblCONSIDERATION.Text = Convert.ToString(dtaReader\["CONSIDERATION"\]);
                     lblCURR.Text = Convert.ToString(dtaReader\["CURR"\]);
                     lblCons\_Curr.Text = Convert.ToString(dtaReader\[
    
    S 1 Reply Last reply
    0
    • F ferronrsmith

      I am a noob working a webpage, i wanna pass multiple values from a select box in a query string so that a report may be generated any one can help me please. So basically, if the user enters only one value, only 1 report is queried if they entered more than 1 then more than one report is generated one after another. this is the code i already have, it only make one query to the database now. I want the reports to be created one below the other.... and so on.

      using System;
      using System.Collections.Generic;
      using System.Data;
      using System.Data.SqlClient;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;

      namespace SealRegister
      {
      public partial class _Default : System.Web.UI.Page
      {

          protected void Page\_Load(object sender, EventArgs e)
          {
              try
              {
                  string connstring = @"Data Source=FGVMDEVSVR;Initial Catalog=FGBInvestment;uid=sa;pwd=Wizard1;";
                  //string connstring = @"Data Source=FGBMIS01\\SQLEX;Database=FGBInvestments;Trusted\_Connection=yes;User Id;Password=";
                  SqlConnection conn = new SqlConnection(connstring);
                  SqlCommand cmd = conn.CreateCommand();
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd.CommandText = "sp\_getTransfer";
      
                  //create parameters to provide the input
                  SqlParameter parInput1 = cmd.Parameters.Add("@TRANSFER\_ID", SqlDbType.Int);
                  parInput1.Direction = ParameterDirection.Input;
                  parInput1.Value =  Request.QueryString\["TRANSFER\_ID"\];
      
      
                  //execute stored procedure
                  conn.Open();
      
                  SqlDataReader dtaReader;
                  dtaReader = cmd.ExecuteReader();
                  while (dtaReader.Read())
                  {
                      //Associate service fields names and types from database to elements in smsValues array
                       lblIMID.Text = Convert.ToString(dtaReader\["IMID"\]);
                       lblDESCRIPTION.Text = Convert.ToString(dtaReader\["DESCRIPTION"\]);
                       lblAMOUNT.Text = Convert.ToString(dtaReader\["AMOUNT"\]);
                       lblAMOUNT\_TRANSFER.Text = Convert.ToString(dtaReader\["AMOUNT\_TRANSFER"\]);
                       lblCONSIDERATION.Text = Convert.ToString(dtaReader\["CONSIDERATION"\]);
                       lblCURR.Text = Convert.ToString(dtaReader\["CURR"\]);
                       lblCons\_Curr.Text = Convert.ToString(dtaReader\[
      
      S Offline
      S Offline
      sudhanvag
      wrote on last edited by
      #2

      ferronrsmith wrote:

      So basically, if the user enters only one value, only 1 report is queried if they entered more than 1 then more than one report is generated one after another.

      What do you mean report here?? Is it a crystal report? I dont see any report binding code. I would appreciate if you elaborate your requirement. Cheers, Sudhanva

      F 1 Reply Last reply
      0
      • S sudhanvag

        ferronrsmith wrote:

        So basically, if the user enters only one value, only 1 report is queried if they entered more than 1 then more than one report is generated one after another.

        What do you mean report here?? Is it a crystal report? I dont see any report binding code. I would appreciate if you elaborate your requirement. Cheers, Sudhanva

        F Offline
        F Offline
        ferronrsmith
        wrote on last edited by
        #3

        i am cheap, can't afford crystal, lol. I wanna create a form that grabs data from a database and insert it in my layout, the problem i am having is that i want to grab multiple records from the database and display it. Three per page.

        Ferron

        S 1 Reply Last reply
        0
        • F ferronrsmith

          i am cheap, can't afford crystal, lol. I wanna create a form that grabs data from a database and insert it in my layout, the problem i am having is that i want to grab multiple records from the database and display it. Three per page.

          Ferron

          S Offline
          S Offline
          sudhanvag
          wrote on last edited by
          #4

          ferronrsmith wrote:

          I wanna create a form that grabs data from a database and insert it in my layout

          Instead create a usercontrol (which should have your forms' controls) to bind the data, and put a for loop for number of querystring items, and call the usercontrol and bind the data. That should solve your problem. Cheers, Sudhanva

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups