1 Comments

Until now we’ve been happily using Microsoft’s .NET Oracle driver to connect our applications to the database. But recently we started encountering some strange performance problems. We were able to pinpoint the problem to the DataReader and its Read-method. For some reason, the first call to that method was taking really long even though the DataReader was empty. In some queries the call took around 300 milliseconds and sometimes as long as five seconds.

It was obvious only after we tried it: Switching from Microsoft’s driver to Oracle’s .NET driver brought us dramatic performance benefits. Where before our slowest queries took about six seconds to complete, they were now completing in less than 100 ms. Even the queries which we had considered fast saw drastic changes, dropping from 150 ms to 25 ms.

Previously we had two different test environments. Using the Microsoft’s Oracle driver one of our environments was performing OK and the other one was extremely slow (hence the question on StackOverflow). After changing our application to use the Oracle’s driver instead, our slow environment is now fast. And the previously OK working environment is also much faster than before. What is better, we’re getting consistent performance between both of our environments.

Is Microsoft’s .NET Oracle driver broken? Or is there a catch on using the Oracle’s driver? We’re now going through all the things which are different between the two drivers to get a better picture on the subject. If you have experience on this topic I would be glad to hear from them.

0 Comments

I had to go through quite many Oracle scripts last week and one of them was giving the following error:

PLS-00103: Encountered the symbol “CREATE”

As it turns out, if you’re creating a trigger in your Oracle script, you have to include the ‘/’ character after it or you will get this error. Here’s an example of a broken script:

<span style="color: #606060" id="lnum1">   1:</span> CREATE OR REPLACE TRIGGER MY_TRIGGER

<span style="color: #606060" id="lnum2">   2:</span> AFTER UPDATE OF DATA ON TABLE FOR EACH ROW

<span style="color: #606060" id="lnum3">   3:</span> BEGIN

<span style="color: #606060" id="lnum4">   4:</span>     UPDATE TABLE SET DATA=<span style="color: #006080">'Changed data'</span>

<span style="color: #606060" id="lnum5">   5:</span> END;

<span style="color: #606060" id="lnum6">   6:</span>  

<span style="color: #606060" id="lnum7">   7:</span> CREATE VIEW MYDATA_VIEW AS...

But fixing this just requires one new character

<span style="color: #606060" id="lnum1">   1:</span> CREATE OR REPLACE TRIGGER MY_TRIGGER

<span style="color: #606060" id="lnum2">   2:</span> AFTER UPDATE OF DATA ON TABLE FOR EACH ROW

<span style="color: #606060" id="lnum3">   3:</span> BEGIN

<span style="color: #606060" id="lnum4">   4:</span>     UPDATE TABLE SET DATA=<span style="color: #006080">'Changed data'</span>

<span style="color: #606060" id="lnum5">   5:</span> END;

<span style="color: #606060" id="lnum6">   6:</span> /

<span style="color: #606060" id="lnum7">   7:</span> CREATE VIEW MYDATA_VIEW AS...

3 Comments

Having been busy with a small DotNetNuke-based project lately so here’s a short “how-to” for those who want to use jQuery in their own DNN-modules. This applies to DNN 5.0 and newer.

1. Installing jQuery

DNN by default includes the jQuery library so no manual installation is required. You can check the jQuery version from Host – Host settings – Advanced Settings – JQuery settings. This is also the place where you can make DNN to use Microsoft’s or Google’s CDN to deliver the library. If your module targets the version 5.0 of DNN (actually, 4.9.1) or newer, you can be sure that every installation includes the jQuery.

dnn_jquery

2. Request jQuery in code-behind

In your module, make sure to request for jQuery in code-behind class. Module’s Load-event is excellent place for this:

   1: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   2:
   3:     Try
   4:
   5:         If Not Page.IsPostBack Then
   6:
   7:             DotNetNuke.Framework.jQuery.RequestRegistration()
   8:
   9:         End If
  10:
  11:     Catch exc As Exception
  12:         ProcessModuleLoadException(Me, exc)
  13:     End Try
  14:
  15: End Sub

3. Use the jQuery-word instead of $-character

For some reason the widely used jQuery-shortcut ‘$’ doesn’t always work properly inside the DotNetNuke. So it’s better to use the word jQuery instead. Here’s an example of using jQuery in the traditional way:

   1: <script type="text/javascript">
   2:     $(document).ready(function() {
   3:         $("#featured > ul").tabs({ fx: { opacity: "toggle"} }).tabs("rotate", 7500, true);
   4:     });
   5: </script>

In DotNetNuke it’s better to write the function like the following:

   1: <script type="text/javascript">
   2:     jQuery(document).ready(function() {
   3:         jQuery("#featured > ul").tabs({ fx: { opacity: "toggle"} }).tabs("rotate", 7500, true);
   4:     });
   5: </script>
And that’s it. Following these small steps you can easily use jQuery to enhance the functionalities of your custom DNN modules.

0 Comments

Here’s a snippet which has saved me a great deal of time lately. It’s a simple function which takes in a XmlSchema-object and returns it in a string-format.

<span id="lnum1" style="color: #606060">   1:</span> <span style="color: #0000ff">Private</span> <span style="color: #0000ff">Function</span> SchemaAsString(<span style="color: #0000ff">ByVal</span> schema <span style="color: #0000ff">As</span> XmlSchema) <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span>

<span id="lnum2" style="color: #606060">   2:</span>&nbsp; 

<span id="lnum3" style="color: #606060">   3:</span>     Using memStream <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> MemoryStream(1024)

<span id="lnum4" style="color: #606060">   4:</span>&nbsp; 

<span id="lnum5" style="color: #606060">   5:</span>         schema.Write(memStream)

<span id="lnum6" style="color: #606060">   6:</span>         memStream.Seek(0, SeekOrigin.Begin)

<span id="lnum7" style="color: #606060">   7:</span>&nbsp; 

<span id="lnum8" style="color: #606060">   8:</span>         Using reader <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> StreamReader(memStream)

<span id="lnum9" style="color: #606060">   9:</span>&nbsp; 

<span id="lnum10" style="color: #606060">  10:</span>             <span style="color: #0000ff">Dim</span> result = reader.ReadToEnd

<span id="lnum11" style="color: #606060">  11:</span>             <span style="color: #0000ff">Return</span> result

<span id="lnum12" style="color: #606060">  12:</span>&nbsp; 

<span id="lnum13" style="color: #606060">  13:</span>         <span style="color: #0000ff">End</span> Using

<span id="lnum14" style="color: #606060">  14:</span>&nbsp; 

<span id="lnum15" style="color: #606060">  15:</span>     <span style="color: #0000ff">End</span> Using

<span id="lnum16" style="color: #606060">  16:</span>&nbsp; 

<span id="lnum17" style="color: #606060">  17:</span> <span style="color: #0000ff">End</span> Function

This is useful if you obtain a XmlSchema-object from somewhere and want to do some Linq to Xml queries over it.

The original code was found from the StackOverflow.

0 Comments

When using NHibernate with an Oracle db, executing a stored procedure is simple. But it has a twist. Instead of using the keyword “exec”, you must use “call”.

<span id="lnum1" style="color: #606060">   1:</span> var query = session.CreateSQLQuery(<span style="color: #006080">"call MY_PROCEDURE ('Param1', 'Param2')"</span>);

<span id="lnum2" style="color: #606060">   2:</span> query.ExecuteUpdate();