mardi 24 février 2015

when i'm using 3 tier insertion try-catch, showingstack overflow exception..i'm new to the try-catch block pls help me!


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


namespace Wpf_threetier_test
{

public class DAL
{

SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=DATABASE_THOTH;Integrated Security=True");
SqlCommand cmd;



public string inset( BAL objbal)
{

try
{

con.Open();
cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "sp_test_db";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", objbal.Name);
cmd.Parameters.AddWithValue("@email", objbal.Email);
cmd.Parameters.AddWithValue("@flag", "insert");
cmd.ExecuteNonQuery();
con.Close();
string output = "saved in to the data base";
return output;

}
catch(NoNullAllowedException x)
{

return null;
}


finally
{
con.Dispose();
}




}

}
}

Aucun commentaire:

Enregistrer un commentaire