Using CommerceBuilder API from standalone windows/consol app
Posted: Thu May 07, 2009 10:52 am
I'd like to create a standalone windows or console application that I can use in testing/qa to manipulate data in the database.
This simplest thing I am trying to do is write a windows app that creates a new user and adds him to the admin group.
This is the code in general. It does not run successfully...
User newUser = UserDataSource.CreateUser(txtUsername.Text+"U", txtUsername.Text, txtPassword.Text, string.Empty, string.Empty, true, 0, out status);
User u = UserDataSource.CreateUser(txtUsername.Text, txtPassword.Text);
u.UserGroups.Add(new UserGroup(u.UserId, g.GroupId));
u.Save();
I have a default data source connection string set up in the app config. And it looks like AC is finding it if I inspect various objects in the debugger. For example if do:
Token tok = Token.Instance;
then inspect tok.Database... I can see my connection string in there.
I can't even do something super simple like:
Group g = GroupDataSource.Load(1);
That returns null. No exceptions are throw in any of this so I get no hint as to what the problem is.
How to I do this?
thanks
This simplest thing I am trying to do is write a windows app that creates a new user and adds him to the admin group.
This is the code in general. It does not run successfully...
User newUser = UserDataSource.CreateUser(txtUsername.Text+"U", txtUsername.Text, txtPassword.Text, string.Empty, string.Empty, true, 0, out status);
User u = UserDataSource.CreateUser(txtUsername.Text, txtPassword.Text);
u.UserGroups.Add(new UserGroup(u.UserId, g.GroupId));
u.Save();
I have a default data source connection string set up in the app config. And it looks like AC is finding it if I inspect various objects in the debugger. For example if do:
Token tok = Token.Instance;
then inspect tok.Database... I can see my connection string in there.
I can't even do something super simple like:
Group g = GroupDataSource.Load(1);
That returns null. No exceptions are throw in any of this so I get no hint as to what the problem is.
How to I do this?
thanks