Hay there,
I have an asp.net project website with an sql Database. I need to access this same database from another project (a class library that needs to access this database). In fact i want to be able to use the tableadapters that I have implemented for my database in this new class library..
I guess it has to do something with making my database not part of the website but and independemt entitiy that can be seen by others.... I cannot seem to find a way to do that can anyone help meee ??
Thanks for your time!
If its a database then how is it tied to application.
Atleast It must have the mdf files which you can create a real independent entity and then play wiith it using connection strings.
|||
All your databases resides in a databse server (e.g. MS SQL Server 2005).
What you need is to point your ConnectionString from your application to that database.
My guess is, you have two projects (e.g. ProjectA and ProjectB) and thay are using diffrent databases but in some part of ProjectB needs to use the same database of ProjectA.
So, you should have two ConnectionStrings for ProjectB. One you will use it for most part of the project and it is specific to ProjectB (keep it in Web.Config file) while you need another ConnectionString that will access the database (which ProjectA is using it) from ProjectB.
Here, have another ConnectionString in the web.config file of ProjectB and lets it point to the same database used by ProjectA.
Good luck.
|||Hi,
Thanks for your very clear reply and clarification.
I can't seem to apply your reply to my situation as My project B is just a class library i.e. I have no webconfig ...
Note that project A and Project B are part of the same solution too.
Thanks for your help.
Hi ekosha,
Why you have the databse within the project itself?!
|||
Well good question, Well I was just implementing this application then and didn't think I would need to use it from another project. seems that was a wrong decision any idea how I can fix that?
ekosha:
Well good question, Well I was just implementing this application then and didn't think I would need to use it from another project. seems that was a wrong decision any idea how I can fix that?
This database has a file with .mdf extension, take that file and attached to a new database in MS SQL Server.
Now, you can use that database for all your projects (even if they are within one solution).
Good luck.