Self Servicing - Execute Raw SQL?

Posts   
 
    
ianvink
User
Posts: 393
Joined: 15-Dec-2006
# Posted on: 11-Jan-2008 16:45:32   

How do I execute a raw SQL statement? Is it possible?

sql = "update blah blah";

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 11-Jan-2008 16:49:47   
ianvink
User
Posts: 393
Joined: 15-Dec-2006
# Posted on: 11-Jan-2008 16:59:36   

Hi Walaa,

I couldn't find a link in those threads to how to execute a SQL statement like :"Update ...." for self servicing though.

Ian

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jan-2008 06:11:59   

Hi Ian,

I think you could achieve that in this way:

// create the desire command
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("update customers set companyName = 'XXXXXX' where customerID = 'YYY'");

// create an action query using a connection created by our DbUtils...
IActionQuery query = new ActionQuery(DbUtils.CreateConnection(), command);

// execute the raw query
int rowsAffected = query.Execute();

Just curious... what kind of query do you want to perform?

David Elizondo | LLBLGen Support Team
Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 14-Jan-2008 02:44:47   

Ooh ... I didn't know you could do that. Thanks simple_smile

Pete

ianvink
User
Posts: 393
Joined: 15-Dec-2006
# Posted on: 14-Jan-2008 14:01:45   

How would I add the ActionQuery to a LLBL transaction? When I try, it errors out:

(Transaction is from ERMS.Services.OneShieldIntegration.DAL.HelperClasses)

transactionManager.Add(query);

Error:

cannot convert from 'SD.LLBLGen.Pro.ORMSupportClasses.IActionQuery' to 'SD.LLBLGen.Pro.ORMSupportClasses.ITransactionalElement'

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 15-Jan-2008 09:39:24   

Would the last post in the following thread be the answer? http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=3947