Jul 22 2010

CRM Workflows Don’t Work, E-mails Don’t Send…

xiao

Symptom: You choose to run a workflow but nothing seems to happen and the new workflow doesn’t appear in the workflow tab.

Theory: If my CRM exam studyage served me right, the Microsoft Dynamics CRM is composed of 3 parts. The application layer producing the business logic, the data layer interfacing with SQL and the async service layer doing stuff like workflows on the background (a bit like SQL agent). If the first 2 break, you won’t get your CRM site at all. When the async service layer breaks, it’s a bit more subtle like in this case. Continue reading


Mar 22 2010

DataGridView Change Cell Data Type After Binding

xiao

I don’t know actually since most of the relevant stuff becomes read-only after filling with data. But my approach is solve this as early on in the process as possible to the entirety of the data and save processing time on a custom loop after.

In other words, your DataGridView is typically bound to a DataTable. That is typically filled with stuff from the database. Make sure your AutoGenerateColumns property is set to true in the DataGridView and select your data to match the type you want to display in the DataGridView. For instance, to get checkboxes,

SELECT ..., CAST(column1 AS bit), ... FROM ...

and change the data type right out of the DataAdapter and DataGridView will figure out the rest automatically


Jul 16 2009

Exclude Views in INFORMATION_SCHEMA

xiao

Another quick tip.
Selecting from INFORMATION_SCHEMA.COLUMNS unfortunately returns also every column in views on top of tables. I never use views and definitely don’t need those columns.

To filter them out, use:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS c
JOING INFORMATION.TABLES t ON c.TABLE_NAME = t.TABLE_NAME
AND t.TABLE_TYPE = 'BASE TABLE'

Jun 21 2009

.NET Compare 2 Datarows by Value Using LINQ

xiao

There are too many top Google search results giving the impression that it is impossible to compare 2 DataRows for its value contents and the programmer needs to iterate through everything himself.

Such is no longer true in .NET 3.5 but the blogosphere doesn’t seem to have caught on yet.

It is possible, given 2 DataTables or any other enumerable object types, to compare its contents using LINQ in just one line of code.

I will give an example in VB where I’d want to compare all column properties (description, data type, field length, etc) of all tables in 2 supposedly identical SQL databases. Continue reading


Jun 15 2009

SQL Server Check User Permissions

xiao

Another quick solution for users of MSSQL Server. fn_my_permissions and results

To view the permissions the current logged SQL user has, use the command

SELECT * FROM fn_my_permissions(NULL, 'DATABASE')

or variations to return a list of SQL commands permitted.

For more details, visit the MSDN page