about get connection string from app.config
-
two projects,BusinessLayer and DataAcessLayer. DataAcessLayer includes CustomerDB.cs, App.config. App.config is like this: CustomerDB class has method GetCustomers public DataTable GetCustomers() { string ConnectionString = ConfigurationSettings.AppSettings ["ConncetionString"]; ............ } when i call GetCustomers() in BusinessLayer, the ConncetionString is always null. but i did have a successful try before. please help me,thanks. -- modified at 23:06 Tuesday 27th September, 2005
-
two projects,BusinessLayer and DataAcessLayer. DataAcessLayer includes CustomerDB.cs, App.config. App.config is like this: CustomerDB class has method GetCustomers public DataTable GetCustomers() { string ConnectionString = ConfigurationSettings.AppSettings ["ConncetionString"]; ............ } when i call GetCustomers() in BusinessLayer, the ConncetionString is always null. but i did have a successful try before. please help me,thanks. -- modified at 23:06 Tuesday 27th September, 2005
just a WAG... You might want to try including an \ before each of the quotes in your connection string. There also seems to be a missing quote after Server Name =" If the value needs to be null I would try: Server Name =\"\" Provider might also need to use \" instead of ' but alas it's just a WAG and I'm sure someone else will point me (or you) the right way Let me know if it works. www.lovethosetrains.com
-
just a WAG... You might want to try including an \ before each of the quotes in your connection string. There also seems to be a missing quote after Server Name =" If the value needs to be null I would try: Server Name =\"\" Provider might also need to use \" instead of ' but alas it's just a WAG and I'm sure someone else will point me (or you) the right way Let me know if it works. www.lovethosetrains.com
i delete some detail of the connection string because here is messageboards. i can get right value of connection string if i call GetCustomers() in project DataAccessLayer. but if i call GetCustomers() in BusinessLayer the conncetion string is always null. thanks anyway.
-
just a WAG... You might want to try including an \ before each of the quotes in your connection string. There also seems to be a missing quote after Server Name =" If the value needs to be null I would try: Server Name =\"\" Provider might also need to use \" instead of ' but alas it's just a WAG and I'm sure someone else will point me (or you) the right way Let me know if it works. www.lovethosetrains.com
-
two projects,BusinessLayer and DataAcessLayer. DataAcessLayer includes CustomerDB.cs, App.config. App.config is like this: CustomerDB class has method GetCustomers public DataTable GetCustomers() { string ConnectionString = ConfigurationSettings.AppSettings ["ConncetionString"]; ............ } when i call GetCustomers() in BusinessLayer, the ConncetionString is always null. but i did have a successful try before. please help me,thanks. -- modified at 23:06 Tuesday 27th September, 2005
-
How are the projects related? Have you referenced the business layer in the web project? --- b { font-weight: normal; }
there were two project BLL and DAL, BLL use DAL to complete some CRUD jobs. i have referenced DAL in BLL. thanks ^_^
-
there were two project BLL and DAL, BLL use DAL to complete some CRUD jobs. i have referenced DAL in BLL. thanks ^_^
Ok I'll byte again... by chance are u creating a new instance of your DAL in BLL and then not reading the app.config? If the variable holding your connection string is not static then it would be null when you created a new instance of DAL. You could try declaring your connection string variable in DAL as static (might not be good practice) and see what you get. I was thinking maybe your method only returns a (GET) value and does not actually go out and read the app.config. :+) www.lovethosetrains.com -- modified at 22:20 Wednesday 28th September, 2005