Once again I need your help. I have a webpage in my web application. On page load, it looks up the credit limit and the accounts receivable of an agent. Below is my code and works fine if the accounts receivable has value:
- private void GetCreditLimit()
- {
- using (SqlConnection con = DBConnection.GetDbCon())
- {
- SqlCommand cmd = new SqlCommand("spGetAgentCreditLimitAndARBalance", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@AgentID", lblAgentCode.Text);
- using (SqlDataAdapter da = new SqlDataAdapter(cmd))
- {
- DataSet ds = new DataSet();
- da.Fill(ds);
- try
- {
- lblCreditLimit.Text = ds.Tables[0].Rows[0]["CreditLimit"].ToString();
- lblARBalance.Text = ds.Tables[0].Rows[0]["ARBalance"].ToString();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- }
- }
- Server Error in '/' Application.
- There is no row at position 0.
- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
- Exception Details: System.IndexOutOfRangeException: There is no row at position 0.
Thanks for your help.


Rafnas T PRank #280 · 8.8K reputationPosted May 12, 2017, 1:13 AM EDT
{
Amit GuptaRank #190 · 12.8K reputationPosted May 11, 2017, 10:49 PM EDT
Jes SieRank #1,285 · 1.3K reputationPosted May 12, 2017, 12:15 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted May 12, 2017, 12:24 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted May 12, 2017, 1:05 AM EDT
Jes SieRank #1,285 · 1.3K reputationPosted May 12, 2017, 1:12 AM EDT