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 PPosted May 12, 2017, 5:13 AM
{
Jes SiePosted May 12, 2017, 5:12 AM
Rafnas T PPosted May 12, 2017, 5:05 AM
Amit GuptaPosted May 12, 2017, 4:24 AM
Jes SiePosted May 12, 2017, 4:15 AM
Amit GuptaPosted May 12, 2017, 2:49 AM