Hi Mike / Logan,
We used to have the nice hooks in 5.5 (cbDatabase Class - QueryArray, QueryArrayIC, QueryValue, etc) for querying the database from the codebehind without having to setup connection, recordset, etc... it was VERY useful for adhoc queries.
I don't see that in 7.0 API... do you still have it? If so, can you provide help on where it is?
If not, the connection string is encrypted and not sure which method to use to unencrypt it...
Let us know?
Thanks.
-sri
sri@awcs.net
AC 7.0 - Querying DB option removed?
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
We have a similar database wrapper in AC7, though it is provided by the Microsoft enterprise library. Our database class is Microsoft.Practices.EnterpriseLibrary.Data.Database.
CommerceBuilder.Common.Token is a singleton, it provides a static property to get the current instance of the token:
The token instance holds a reference to the database.
The database class has useful methods like ExecuteScalar, ExecuteDataSet, and ExecuteReader. You can use these methods with ad-hoc queries. They can be used with parameters as well.
Example from our code of ExecuteScalar:
Hope this gets you pointed in the right direction.
CommerceBuilder.Common.Token is a singleton, it provides a static property to get the current instance of the token:
Code: Select all
Token acToken = Token.Instance;
Code: Select all
Microsoft.Practices.EnterpriseLibrary.Data.Database database;
database = Token.Instance.Database;
Example from our code of ExecuteScalar:
Code: Select all
int storeId = Token.Instance.StoreId;
Database database = Token.Instance.Database;
DbCommand selectCommand = database.GetSqlStringCommand("SELECT COUNT(*) AS TotalRecords FROM ac_ErrorMessages WHERE StoreId = @storeId");
database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, storeId);
return CommerceBuilder.Utility.AlwaysConvert.ToInt(database.ExecuteScalar(selectCommand));
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
- AbleOne
- AbleCommerce Partner
- Posts: 28
- Joined: Thu Jan 22, 2004 3:47 pm
- Location: Laguna Hills, CA
- Contact:
Awesome Logan.. thank you for the quick response.
Will try and see if I run into any issues.
Thanks.
-sri
sri@awcs.net
Will try and see if I run into any issues.
Thanks.
-sri
sri@awcs.net