I am creating .NET user controls and need a database connection. Till now I used the .NET way of connection to a database (example:
Sql(Ce)Connection myConn = new Sql(Ce)Connection(umbraco.BusinessLogic.Application.SqlHelper.ConnectionString);
)
If someone uses a different database then my user control is useless. I almost can't believe there is no api who checks on wich type of database Umbraco is installed and we can use that to open/close the connection (How are packages developped who uses a database?) but I can't find.
Which is the correct way to connect to the database and automatically use the database where Umbraco is installed on?
Recommanded API to connect to database???
Hello
I am creating .NET user controls and need a database connection. Till now I used the .NET way of connection to a database (example:
)
If someone uses a different database then my user control is useless. I almost can't believe there is no api who checks on wich type of database Umbraco is installed and we can use that to open/close the connection (How are packages developped who uses a database?) but I can't find.
Which is the correct way to connect to the database and automatically use the database where Umbraco is installed on?
You can use the SQL helper that comes with Umbraco.
I think it's located in the namespace umbraco.DataLayer
If you're using Umbraco 6 than you can also use PetaPoco to connect to the database.
It's very usefull if you want to get pocos from you're database query.
Thanks a lot for the replies! I'll give it a try next week, unfortunately I'm not able to do it this week anymore
is working on a reply...