Hi
I get the above error and when removing all try/catch stack trace sais the problem is in the method Conn in my Helper Class in the DAL project.
using System;
using System.Configuration;
namespace DAL
{
public class Helper
{
private static readonly string ConnectionStringName = "AnsiBugDb";
public static string Conn()
{
return ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString;
}
}
}
Can it be, that it is because the name AnsiBugDb is set in the UI project (in App.config) if so, what have I to do to set the db connection in the DAL project instead?
I have tried to copy/paste the text in the ConnectionStringName from the App.Config in the AnsiBug project with no success. I have tried to make a new App.config in the DAL project again without success.
So I'm totally lost in what to do.
I have also tried to set a .ToString() in the return
public static string Conn()
{
return ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString.ToString();
}
I'm using the string in the DalCategory.cs class
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Model.Account;
using System.ComponentModel;
using Dapper;
using System.Linq;
using System.Collections.ObjectModel;
using System.Configuration;
namespace DAL.Account
{
public class DalCategory
{
#region Get
public List<Category> GetCategories()
{
string connectionString = Helper.Conn();
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
{
var list = connection.Query<Category>("dbo.Category_GetAll").ToList();
return list;
}
}
#endregion
#region Insert
#endregion
#region Update
#endregion
#region Delete
#endregion
}
}
I hope someone of you can help me.
Best regards
SimsenVejle :-)