|
|
 Rank: Fanatic
Joined: 9/17/2007 Posts: 264 Location: London, UK.
|
Hi,
I have a very simple user control to handle external redirects. We like to track these without having to go through web logs, so the details are stored to a database.
In code, what's the best way to run the SQL query using the API Umbraco has available?
I know I could track it down eventually but forgive my laziness, I'm hoping 2 mins here will save me 2 hours snooping :)
Richard
2 * 3 * 3 * 37 : The prime factorisation of The Beast.
|
|
 Rank: Addict
Joined: 9/27/2007 Posts: 977 Location: Belgium
|
Hi Richard, umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerHelper() class could be helpful. Just feed it with a connectionstring and you can use any method of which ExecuteNonQuery(string commandText, SqlParameter[] parameters) could be a good candidate to insert some data into the db. Assuming you're using Sql server as backend db, otherwise use any other Helper class already available. Hope that helps. Regards, /Dirk
level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Fanatic
Joined: 7/21/2006 Posts: 253 Location: Salerno - Italy
|
Dirk wrote:Hi Richard,
umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerHelper() class could be helpful. Just feed it with a connectionstring and you can use any method of which
ExecuteNonQuery(string commandText, SqlParameter[] parameters)
could be a good candidate to insert some data into the db.
Assuming you're using Sql server as backend db, otherwise use any other Helper class already available.
Hope that helps. Regards, /Dirk
Particular connectionstring? Red Consulting s.a.s - Umbraco from v1.0
|
|
 Rank: Addict
Joined: 9/27/2007 Posts: 977 Location: Belgium
|
Don't know exactly what you mean, but no, any connectionstring could do. Could be the one in the web.config from the umbraco install, or any other valid connectionstring. Hope that helps. Regards, /Dirk
level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
Rank: Newbie
Joined: 9/9/2008 Posts: 17 Location: Berkley, MI
|
nm
|
|
Rank: Newbie
Joined: 10/22/2008 Posts: 4 Location: Copenhagen
|
umbraco.BusinessLogic.Application.SqlHelper comes initialized and all...
|
|
 Rank: Aficionado
Joined: 11/16/2007 Posts: 155 Location: Surrey, UK
|
I've only just started doing this sort of stuff, but I have code like Code: logGrid.DataSource = SqlHelper.ExecuteDataset(umbraco.GlobalSettings.DbDSN, CommandType.Text, "SQL statement goes here...");
and it works fine.
Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
|
|
|
Guest |