类型为';System.StackOverflowException';发生在DAL.dll中

本文关键字:DAL dll StackOverflowException System 类型 | 更新日期: 2023-09-27 18:25:31

我遇到了以上错误,找不到合适的解决方案。请帮帮我。我也在谷歌上搜索这个错误,但我没有得到蚂蚁的解决方案。

我的数据访问如下

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; }
    }
}

类型为';System.StackOverflowException';发生在DAL.dll中

您正试图将存储过程返回的整个结果集强制转换为整数值,此处的"id=Convert.ToInt32(cmd.ExecuteScaler());"可能超出整数的内存范围。在该语句处放置断点,然后查看堆栈跟踪。