1 Solution.
2 Projects (1.WEB - 2. Three Layered Structure)
Calling a stored procedure: Web -> BOL -> BLL -> DAL.
DAL's Method: gets the connection string and the executes.
public DataSet ExecuteSQL(string sp, Persona user)
{
EH eh = new EH(); // Error_Handling.cs object
try
{
DataSet ds = new DataSet();
string connectionString = null;
connectionString = GetNewConnection("BO"); //HERE COMES THE ERROR
SqlConnection conn = new SqlConnection(connectionString);
using (conn)
{ ....
GetNewConnection().
public string GetNewConnection(string server)
{
return ConfigurationManager.ConnectionStrings["BO"].ConnectionString;
}
App.Config fragment naming the desired connection
<connectionStrings>
<add name="BO"
connectionString="Data Source=Server;Initial Catalog=BO;User ID=WebUser;Password=333;Integrated Security=False"
providerName="System.Data.SqlClient" />
I get the following Exception when returning from GetNewConnection()
- $exception {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}
Why is it getting a null reference?
GetNewConnection, shouldn't you use theserverargument instead of hard coding"BO"?