未处理的类型' System.StackOverflowException'发生在DAL.dll中

时间:2014-10-05 04:48:34

标签: c# asp.net

我遇到上述错误,我找不到合适的解决方案。请帮我。我也谷歌关于这个错误,但我没有得到它的蚂蚁解决方案。

我的数据访问如下

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BAL;

namespace DAL
{
    public class dlvisa
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ParmarConnection"].ConnectionString);
        public int INS(blvisa bl)
        {
            int id = 0;
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_Visa_Master", con);
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {

                cmd.Parameters.AddWithValue("@Visa_Id", bl.Visa_Id);
                cmd.Parameters.AddWithValue("@Visa_type_Id", bl.Visa_type_Id);
                cmd.Parameters.AddWithValue("@Arrival_date", bl.Arrival_date);
                cmd.Parameters.AddWithValue("@Currency", bl.Currency);
                cmd.Parameters.AddWithValue("@Name", bl.Name);
                cmd.Parameters.AddWithValue("@Email", bl.Email);
                cmd.Parameters.AddWithValue("@Mob", bl.Mob);
                cmd.Parameters.AddWithValue("@NoOfAdult", bl.NoOfAdult);
                cmd.Parameters.AddWithValue("@NoOfChild", bl.NoOfChild);
                cmd.Parameters.AddWithValue("@NoOfInfant", bl.NoOfInfant);
                cmd.Parameters.AddWithValue("@PriceOfAdult", bl.PriceOfAdult);
                cmd.Parameters.AddWithValue("@PriceOfChild", bl.PriceOfChild);
                cmd.Parameters.AddWithValue("@PriceOfInfant", bl.PriceOfInfant);
                cmd.Parameters.AddWithValue("@TotalPrice", bl.TotalPrice);
                cmd.Parameters.AddWithValue("@mode", bl.Mode);
                id = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();
            }
            catch (Exception)
            {


            }
            return id;
        }

        public void Insert_Trn_Visa(blvisa bl)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_Trn_Visa", con);
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cmd.Parameters.AddWithValue("@Trn_Visa_Id", bl.Trn_Visa_Id);
                cmd.Parameters.AddWithValue("@Visa_Id", bl.Visa_Id);
                cmd.Parameters.AddWithValue("@PhotoCopy", bl.PhotoCopy);
                cmd.Parameters.AddWithValue("@Passport1", bl.Passport1);
                cmd.Parameters.AddWithValue("@Passport2", bl.Passport2);
                cmd.Parameters.AddWithValue("@Name", bl.ParticularName);
                cmd.Parameters.AddWithValue("@mode", bl.Mode);
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception)
            {


            }
        }

        public DataSet BindDummyRows(blvisa visa)
        {
            DataSet ds = new DataSet();
            con.Open();
            SqlCommand cmd = new SqlCommand("DummyRows", con);
            SqlDataAdapter da = new SqlDataAdapter();
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                cmd.Parameters.AddWithValue("@Rows", visa.RowNo);
                cmd.Connection = con;
                da.SelectCommand = cmd;
                da.Fill(ds);
                con.Close();
            }
            catch (Exception)
            {

            }

            return ds;
        }

    }
}

我的业务层如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BAL
{
    public class blvisa
    {
        public int RowNo { get; set; }
        public int Visa_Id { get; set; }
        public int Visa_type_Id { get; set; }
        public DateTime Arrival_date { get; set; }
        public string Currency { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string Mob { get; set; }
        public int NoOfAdult { get; set; }
        public int NoOfChild { get; set; }
        public int NoOfInfant { get; set; }
        public decimal PriceOfAdult { get; set; }
        public decimal PriceOfChild { get; set; }
        public decimal PriceOfInfant { get; set; }
        public decimal TotalPrice { get; set; }
        public string Mode { get; set; }

        public int Trn_Visa_Id { get; set; }
        public string PhotoCopy { get; set; }
        public string Passport1 { get; set; }
        public string Passport2 { get; set; }
        public string ParticularName { get; set; }
    }
}

1 个答案:

答案 0 :(得分:0)

您正在尝试将存储过程返回的整个结果集返回到整数值,这里" id = Convert.ToInt32(cmd.ExecuteScalar());"这可能会超过整数的内存范围。在此语句中放置一个断点并查看堆栈跟踪。