Friday, September 20, 2024

Microsoft CRM integration: Oracle database access from MS CRM

Today’s article topic is a customization possibility demonstration for the user web interface of Microsoft CRM.

As an example we’ll use MS CRM integration with an ASP.Net application, accessing customer data access, when customers are stored in Oracle 10g database. Let’s begin:

1. First, let’s create the table to store customer information in Oracle database. We’ll use web application iSQL for table metadata manipulation:

2. Table is now created and contains four fields: CUSTOMER_ID, FIRST_NAME, LAST_NAME и ADDRESS. Fill it with text data:

3. Now we’ll work with data access to Oracle database from ASP.Net application. We should download from Oracle site http://www.oracle.com Windows Instant Client. We don’t have to install it – just unpack all the files in the directory of your choice, for example c:\oracle and set environmental variable TNS_ADMIN, pointing to this directorty.

4. In c:\oracle directory (or where TNS_ADMIN point out) create file tnsnames.ora as following (change host and service names):

ORCL1 =
&nbsp (DESCRIPTION =
&nbsp&nbsp (ADDRESS = (PROTOCOL = TCP)(HOST = oraclehost.youtdomain.com)(PORT = 1521))
&nbsp&nbsp (CONNECT_DATA =
&nbsp&nbsp&nbsp (SERVER = DEDICATED)
&nbsp&nbsp&nbsp (SERVICE_NAME = ORCL1)
&nbsp&nbsp )
&nbsp )

5. Make correction to windows registry to have MS SQL Linked Server work properly withOracle OLE DB Provider. In the hive KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\MTxOCI make these changes:

OracleXaLib = "oracleclient8.dll"
OracleSqlLib = "orasql8.dll"
OracleOciLib = "oci.dll"

6. Now let’s create Linked Server in MS SQL Server 2000:

Note: in the Security tab we need to use security context with the credentials, having valid access to Oracle Database.

7. Linked Server is ready – let’s test it functioning – open table list. We should see customer table there:

8. Now we’ll create stored procedure for Oracle data access:

SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
GO

CREATE PROCEDURE MyCustomersList AS

SELECT * FROM OPENQUERY(ORACLE, 'SELECT * FROM Customer')

RETURN

9. Next step is customizing Microsoft CRM using interface. We’ll add customer list button into Quote screen toolbar. Edit isv.config:

Change Url to your host name.

10. To create ASPX page we’ll use RAD for ASP.Net – WebMatrix:

11. Create new page for data access:

12. Change it’s code to access our data:

Sub Page_Load(Sender As Object, E As EventArgs)

&nbsp&nbsp Dim ConnectionString As String = "server=(local);database=Albaspectrum;trusted_connection=true"
&nbsp&nbsp Dim CommandText As String = "EXEC MyCustomersList"

&nbsp&nbsp Dim myConnection As New SqlConnection(ConnectionString)
&nbsp&nbsp Dim myCommand As New SqlCommand(CommandText, myConnection)

&nbsp&nbsp myConnection.Open()

&nbsp&nbsp DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
&nbsp&nbsp DataGrid1.DataBind()
End Sub

13. Now we’ll test our web application by calling it from MS CRM.

Boris Makushkin is senior software developer in Alba Spectrum Technologies US nation-wide Great Plains, Microsoft CRM customization company, based in Chicago and having locations in multiple states and internationally (www.albaspectrum.com ), he is Unix, SQL, C#.Net, Crystal Reports, Microsoft CRM SDK and Exchange Server SDK developer. You can reach Boris: borism@albaspectrum.com

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles