Best Way To Execute A SQL Query in User Control? Options
VirtualRichard
Posted: Tuesday, August 19, 2008 11:18:45 AM

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.
Dirk
Posted: Tuesday, August 19, 2008 11:52:35 AM

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
Ig_p118
Posted: Monday, September 01, 2008 9:18:34 AM
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
Dirk
Posted: Monday, September 01, 2008 9:26:06 AM

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
MPiccinato
Posted: Tuesday, September 30, 2008 9:56:16 PM
Rank: Newbie

Joined: 9/9/2008
Posts: 17
Location: Berkley, MI
nm

friism
Posted: Tuesday, November 04, 2008 2:17:24 PM
Rank: Newbie

Joined: 10/22/2008
Posts: 4
Location: Copenhagen
umbraco.BusinessLogic.Application.SqlHelper comes initialized and all...
ascendinternet
Posted: Tuesday, November 04, 2008 3:14:05 PM

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)
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.