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. Web Development
  3. ASP.NET
  4. procedure returning no data even though data is present in database

procedure returning no data even though data is present in database

Scheduled Pinned Locked Moved ASP.NET
csharpdatabaseasp-net
5 Posts 3 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.
  • D Offline
    D Offline
    developerit
    wrote on last edited by
    #1

    hi, iam using asp.net2.0 with c#, with backend sql server2000 in my client system i have to create dynamically procedure and return the result but when iam using in my local system the code is working fine but at client system it it not working can you correct my code which helps me

    string strcon = "Data Source=";strcon += Request.Params["REMOTE_ADDR"] + ";" + "Initial Catalog=POS;User ID=sa;Password=xx103";

    SqlConnection conproc = new SqlConnection(strcon);
    conproc.Open();
    SqlCommand cmdproc = new SqlCommand("getsum", conproc);
    cmdproc.CommandType = CommandType.StoredProcedure;

        cmdproc.Parameters.AddWithValue("@BranchKey", Convert.ToInt32(Session\["BranchKey"\]));
        DateTime dt = Convert.ToDateTime(txtfrom.Text.ToString());
        string fromDate = dt.ToShortDateString();
        DateTime dt1 = Convert.ToDateTime(txtto.Text.ToString());
        string toDate = dt1.ToShortDateString();
    
    
        cmdproc.Parameters.AddWithValue("@FromDate", SqlDbType.SmallDateTime).Value = fromDate;
        cmdproc.Parameters.AddWithValue("@ToDate", SqlDbType.SmallDateTime).Value=toDate;
    
        SqlParameter p1 = cmdproc.Parameters.Add("@tot", SqlDbType.Decimal);
        p1.Direction = ParameterDirection.Output;
        if ((Convert.ToInt32(cmdproc.ExecuteNonQuery())!= -1) && (cmdproc.Parameters\["@tot"\].Value)!= DBNull.Value)
        {
            decimal ot = Convert.ToDecimal(cmdproc.Parameters\["@tot"\].Value);
            //decimal ot = Convert.ToDecimal(p1.Value);
            if (ot != null)
            {
                txttotal.Text = ot.ToString();
                conproc.Close();
            }
        }
        else
        {
    
    
            clsdataset.ShowAlertMessage("No Data");
            txttotal.Text = "";
    
        }
    
    T S 2 Replies Last reply
    0
    • D developerit

      hi, iam using asp.net2.0 with c#, with backend sql server2000 in my client system i have to create dynamically procedure and return the result but when iam using in my local system the code is working fine but at client system it it not working can you correct my code which helps me

      string strcon = "Data Source=";strcon += Request.Params["REMOTE_ADDR"] + ";" + "Initial Catalog=POS;User ID=sa;Password=xx103";

      SqlConnection conproc = new SqlConnection(strcon);
      conproc.Open();
      SqlCommand cmdproc = new SqlCommand("getsum", conproc);
      cmdproc.CommandType = CommandType.StoredProcedure;

          cmdproc.Parameters.AddWithValue("@BranchKey", Convert.ToInt32(Session\["BranchKey"\]));
          DateTime dt = Convert.ToDateTime(txtfrom.Text.ToString());
          string fromDate = dt.ToShortDateString();
          DateTime dt1 = Convert.ToDateTime(txtto.Text.ToString());
          string toDate = dt1.ToShortDateString();
      
      
          cmdproc.Parameters.AddWithValue("@FromDate", SqlDbType.SmallDateTime).Value = fromDate;
          cmdproc.Parameters.AddWithValue("@ToDate", SqlDbType.SmallDateTime).Value=toDate;
      
          SqlParameter p1 = cmdproc.Parameters.Add("@tot", SqlDbType.Decimal);
          p1.Direction = ParameterDirection.Output;
          if ((Convert.ToInt32(cmdproc.ExecuteNonQuery())!= -1) && (cmdproc.Parameters\["@tot"\].Value)!= DBNull.Value)
          {
              decimal ot = Convert.ToDecimal(cmdproc.Parameters\["@tot"\].Value);
              //decimal ot = Convert.ToDecimal(p1.Value);
              if (ot != null)
              {
                  txttotal.Text = ot.ToString();
                  conproc.Close();
              }
          }
          else
          {
      
      
              clsdataset.ShowAlertMessage("No Data");
              txttotal.Text = "";
      
          }
      
      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #2

      Are you getting any error? you didn't mentioned that. I guessed one thing, Is your client machine have database? Then Handle the exception using Try..Catch. Reply the details so that we can help you.

      thatraja


      Tips/Tricks|Brainbench certifications|Facebook|Twitter

      D 1 Reply Last reply
      0
      • T thatraja

        Are you getting any error? you didn't mentioned that. I guessed one thing, Is your client machine have database? Then Handle the exception using Try..Catch. Reply the details so that we can help you.

        thatraja


        Tips/Tricks|Brainbench certifications|Facebook|Twitter

        D Offline
        D Offline
        developerit
        wrote on last edited by
        #3

        hi, my client is also having same database with same tables, client is having data also but displaying no data as a result

        T 1 Reply Last reply
        0
        • D developerit

          hi, my client is also having same database with same tables, client is having data also but displaying no data as a result

          T Offline
          T Offline
          thatraja
          wrote on last edited by
          #4

          what about the error details? then compare the 2 databases verify those are same.

          thatraja


          Tips/Tricks|Brainbench certifications|Facebook|Twitter

          1 Reply Last reply
          0
          • D developerit

            hi, iam using asp.net2.0 with c#, with backend sql server2000 in my client system i have to create dynamically procedure and return the result but when iam using in my local system the code is working fine but at client system it it not working can you correct my code which helps me

            string strcon = "Data Source=";strcon += Request.Params["REMOTE_ADDR"] + ";" + "Initial Catalog=POS;User ID=sa;Password=xx103";

            SqlConnection conproc = new SqlConnection(strcon);
            conproc.Open();
            SqlCommand cmdproc = new SqlCommand("getsum", conproc);
            cmdproc.CommandType = CommandType.StoredProcedure;

                cmdproc.Parameters.AddWithValue("@BranchKey", Convert.ToInt32(Session\["BranchKey"\]));
                DateTime dt = Convert.ToDateTime(txtfrom.Text.ToString());
                string fromDate = dt.ToShortDateString();
                DateTime dt1 = Convert.ToDateTime(txtto.Text.ToString());
                string toDate = dt1.ToShortDateString();
            
            
                cmdproc.Parameters.AddWithValue("@FromDate", SqlDbType.SmallDateTime).Value = fromDate;
                cmdproc.Parameters.AddWithValue("@ToDate", SqlDbType.SmallDateTime).Value=toDate;
            
                SqlParameter p1 = cmdproc.Parameters.Add("@tot", SqlDbType.Decimal);
                p1.Direction = ParameterDirection.Output;
                if ((Convert.ToInt32(cmdproc.ExecuteNonQuery())!= -1) && (cmdproc.Parameters\["@tot"\].Value)!= DBNull.Value)
                {
                    decimal ot = Convert.ToDecimal(cmdproc.Parameters\["@tot"\].Value);
                    //decimal ot = Convert.ToDecimal(p1.Value);
                    if (ot != null)
                    {
                        txttotal.Text = ot.ToString();
                        conproc.Close();
                    }
                }
                else
                {
            
            
                    clsdataset.ShowAlertMessage("No Data");
                    txttotal.Text = "";
            
                }
            
            S Offline
            S Offline
            Satish Mahapatra
            wrote on last edited by
            #5

            I feel executenonquery will return -1 only if it is a procedure if it is a inline query then it will return the affected rows. Just check in DB and let me know whether it is updating in tables or not.

            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