WHAT IS COM, ODBC, OLEDB, ADO

While communicating among various systems from different platforms/technologies(say it ASP.NET or Java), we always come across some basic terms such as ODBC or OLEDB. More importantly COM components. For Microsoft technologies, ADO.NET(ActiveX) or OLEDB is more prominent. Though the basic aim for all these terms are about to be same, there are some differences present among them.

Hierarchical flow for these techniques as per usability restriction and availability for other systems(among heterogeneous systems), from highest to lowest

COM -> OLEDB -> ODBC -> ADO

COM(Component Object Model) : developed by Microsoft. It is not an interface, not methods, not technique. But an idea you can say to enable communication among different heterogeneous systems. Components(commonly known as COM component) can be created in any language based on neccessity and can be used across platforms and technologies.

ODBC(Open Database Connectivity) : developed by “SQL Access Group” which later modified by “Microsoft” and “Simba Tehcnologies” to term it as ODBC. Main use is to access Relational databases(DBMS). This is an interface between the other interfaces and the DBMS. It is based on COM logic.

OLEDB(Object Linking and Embedding Database) : Developed by Microsoft. Successor of ODBC with the additional capability to communicate with non-relational databases such as file system, exchange server file, email etc. It sits purely on the top of COM, actually OLEDB are set of methods(routines) to use COM for communication among various systems. Hence we can say, [ OLEDB = ( ODBC + Non Relational DB Access) ].

ADO(ActiveX Data Object) : Microsoft developed ADO specific to Microsoft related technologies to talk with systems. It is an API that Microsoft allows developer to use and access Relational/ Non-relational DBMS. Bsically ADO uses OLEDB which in turns uses COM logic.

Advertisements

ClickOnce common bugs

Common ClickOnce errors and how to resolve them:

1. Increase the “Publish version” and “publish”
2. Copy all the contents from folder “Application Files”, not the single updated version folder and replace the whole folder in the server completely
3. If error comes, remove contents from folder : “C:\Documents and Settings\UserName\Local Settings\Apps”
4. Check the “Installation Folder URL (if different than above)”. Its should contain path upto the folder name, not the “publish.htm” page

links for reference:

http://stackoverflow.com/questions/1059340/clickonce-error-missing-files-need-to-get-missing-filename
http://msdn.microsoft.com/en-us/library/ms229001.aspx

Get Language specific Month Name from SQL

Since you cannot use data modified scripts inside funcations in SQL server, you cannot use SET LANGUAGE inside a fucntion. Here is the way to get the month name in particular language in SQL server. You can use this function anywhere you want, anywhere you want to call.

Create a scalar valued function with any name, here I am using “fn_GetMonthName”.

Call this function with two parameters passd : “select dbo.fn_GetMonthName ( ‘2012-12-12’, ‘French’)” i.e. first parameter is the datetime value and secod parameter is the language that you want the month in from the date mentioned here.

For example, to get the name of current date in Spanish, you can use :

select dbo.fn_GetMonthName ( GetDate(), ‘Spanish)”

output : Febrero

====================================

CREATE FUNCTION [dbo].[fn_GetMonthName]
( @Date DateTime, @Language NvarChar(100))
RETURNS nvarchar(400)
AS

BEGIN
declare @i int, @m int,@mlist NVARCHAR(1000)

set @m = month(@Date)
set @mlist = (SELECT months FROM sys.syslanguages where alias = @language)
set @i = 1

while(@i < @m)
begin
           set @mlist = replace(@mlist, substring(@mlist,1,charindex(‘,’,@mlist)) ,”)
           set @i = @i + 1
end

set @mlist = (case charindex(‘,’,@mlist) when 0 then @mlist else substring(@mlist,0,charindex(‘,’,@mlist) ) end )
return @mlist
END
GO

====================================

CRM 2011 SQL : retrieve obejctTypeCode for Entity

Since the Solution thing appeared in CRM 2011, you must use “EntityView” or “AttributeView” instead of the convensional Entity, Attribute tables(which are aliases to Metadata tables).

These views have two colums check : OverwriteTime = 0 and ComponentState = 0.

SELECT * FROM [Entity] WHERE OverwriteTime = 0 AND ComponentState = 0

The published solution have OverwriteTime = 0 adn thus it will save your time.

regards

joon

Use old code from CRM 4.0 to access CRM 2011 in C#

Suppose you have a piece of code that accesses CRM 4.0 web service and performs operations. Now, CRM has been updated to 2011 and still you want to use the same old piece of code, without lots of work.

Good news that, CRM 2011 still supports the old web service with the format “http://serverName:portNumber/MSCrmServices/2007/CrmServiceWsdl.aspx?uniquename=organizationName“.

What you need to do is: just replace the same web service in your code with new URL, which is the nothing but with new serverName, portNumber and organizationName for CRm 2011 i.e. “http://serverName:portNumber/MSCrmServices/2007/CrmServiceWsdl.aspx?uniquename=organizationName” with CRM 2011 values.

You are ready to go.

regards

joon

how to use OrganizationServiceClient in CRM 2011(OrganizationServiceClient, Create, Update)

Below are the steps which may be helpful while trying to access CRM 2011 on premise with “OrganizationServiceClient” class. Benefits : no need to use XRM.dll, no early bound class. Also it will help in accessing multiple Organizations in an CRM 2011 installation with the same peice of code without adding the .wsdl file multiple times. It is just like CRm 4.0 with multiple organizations.

Steps:

1. Add Service Request to your VS project with the format “http://CRM ServerName:defaultPort/OrganizationName/XRMServices/2011/Organization.svc“. For example “http://pxtsgo0666:5555/CRMDev/XRMServices/2011/Organization.svc“.

2. Add namespace of that Service Request to your project (using).

3. use below code

==================================================

string strOrg = “CRMDev”;

string strURI = @”http://CRMServerName:defaultPort/&#8221; + strOrg + “/XRMServices/2011/Organization.svc”;

 OrganizationServiceClient orgProxy = new OrganizationServiceClient();

orgProxy.ClientCredentials.Windows.ClientCredential =new System.Net.NetworkCredential(“UserId”, “Password”, “DomainName”);

System.ServiceModel.EndpointAddress myEndpointAdd = new System.ServiceModel.EndpointAddress(newUri strURI), System.ServiceModel.EndpointIdentity.CreateDnsIdentity(“”));

orgProxy.Endpoint.Address= myEndpointAdd;

Entity objAcc = newEntity();

objAcc.LogicalName =“account”;

 AttributeCollection myAttColl = new AttributeCollection();

myAttColl.Add(new KeyValuePair<string,object>(“name”, “AAA from UNTYPE ClientMethod”));

myAttColl.Add(new KeyValuePair<string,object>(“emailaddress1”, testfrom@test.com));

myAttColl.Add(new KeyValuePair<string,object>(“telephone1”, “+1122334455”));

objAcc.Attributes = myAttColl; 

orgProxy.Create(objAcc);

=================================================

Update record:

Entity objAccUpdate = new Entity() { LogicalName = “account”};

 AttributeCollection myAttCollUpd = new AttributeCollection();

myAttCollUpd.Add(new KeyValuePair<string, object>(“emailaddress1”, “UpdatedTestfrom@test.com“));

myAttCollUpd.Add(new KeyValuePair<string, object>(“telephone1”, “+4612312312”));

myAttCollUpd.Add(new KeyValuePair<string, object>(“accountid”, new Guid(“account guid to be updated”) ) );

objAccUpdate.Attributes = myAttCollUpd; 

OrganizationServiceClient_Object.Update(objAccUpdate);

==============================================

Now, you can use the same piece of code to access multiple organizations within the same installation by changing the “strOrg” variable. Here an account record is being created.

Note: you must create a DNS Name separately with statement “System.ServiceModel.EndpointAddress myEndpointAdd = new System.ServiceModel.EndpointAddress(new Uri(strURI),System.ServiceModel.EndpointIdentity.CreateDnsIdentity(“”));”

Here you can pass any value while creating DNS identity ( CreateDnsIdentity(“xyz”) ). You can use also below line if you dont want to create DNS, but want to have UPN Identity :

System.ServiceModel.EndpointAddress myEndpointAdd = new System.ServiceModel.EndpointAddress(new Uri(strURI), System.ServiceModel.EndpointIdentity.CreateUpnIdentity(“1@1”), //string.Format(“{0}@{1}”, _user, “_domain”)),

new System.ServiceModel.Channels.AddressHeader[] { });

regards

joon