procedure returning no data even though data is present in database
-
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 = ""; }
-
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 = ""; }
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
-
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
hi, my client is also having same database with same tables, client is having data also but displaying no data as a result
-
hi, my client is also having same database with same tables, client is having data also but displaying no data as a result
what about the error details? then compare the 2 databases verify those are same.
thatraja
-
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 = ""; }
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.