fredag 1 april 2016

Oracle: Convert CLOB to varchar

Had problem to read oracle table with column declared as CLOB if it contained more than 4000 byte of data.
Solved it by devide the column into smaller parts, with following select statement;


Select NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,1)),'') AS CLOB_COL_Part1,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,3001)),'') AS CLOB_COL_Part2,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,6001)),'') AS CLOB_COL_Part3,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,9001)),'') AS CLOB_COL_Part4,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,12001)),'') AS CLOB_COL_Part5,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,15001)),'') AS CLOB_COL_Part6,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,18001)),'') AS CLOB_COL_Part7,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,21001)),'') AS CLOB_COL_Part8,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,24001)),'') AS CLOB_COL_Part9,
      NVL(TO_CHAR(DBMS_LOB.SUBSTR(CLOB_COL,3000,27001)),'') AS CLOB_COL_Part10

       DBMS_LOB.getlength(CLOB_COL) AS CLOB_COL_LENGTH,

from DATABASE_TABLE


I use this to copy the data into an Excel file, and there the data can be concatenated again.

måndag 21 mars 2016

Convert $#@ to ÅÄÖ and }{| to åäö

If swedish characters are saved in strange format in DB2, propably due to wrong ebcdic/asscii conversion, use DB2 command "Translate" as in below example:


Select USERID, ORG_UNIT, COMPANY,
       Translate(GIVEN_NAME,'åäöÅÄÖé', '}{¦$#@`') AS GIVEN_NAME,
       Translate(MIDDLE_NAME,'åäöÅÄÖé', '}{¦$#@`') AS MIDDLE_NAME,
       Translate(SURNAME,'åäöÅÄÖé', '}{¦$#@`') AS SURNAME,
       EMPL_NO, EMPL_START, EMPL_END, EMPL_TYPE, COST_CENTER, DEPARTMENT, OFFICE,
       Translate(CITY,'åäöÅÄÖé', '}{¦$#@`') AS CITY,
       Translate(STATE,'åäöÅÄÖé', '}{¦$#@`') AS STATE,
       TELE_NO, MOBILE,
       Translate(CONS_COMPANY,'åäöÅÄÖé', '}{¦$#@`') AS CONS_COMPANY,
       EXT_UID
from DB2TableName
whereTranslate(CITY,'åäöÅÄÖé', '}{¦$#@`') = 'Göteborg'


tisdag 26 augusti 2014

hittaITorslanda.se

Please visit my new web site:  hittaitorslanda.se

sitemap.php

Example of sitemap.php:

<?php header('Content-type: text/xml');
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'";
echo "  xmlns:image='http://www.google.com/schemas/sitemap-image/1.1'";
echo "  xmlns:video='http://www.google.com/schemas/sitemap-video/1.1'>";

echo "  <url><loc>";
echo "http://www.hittaitorslanda.se/index.php";
echo " </loc></url>";

$xml=simplexml_load_file(getcwd() . "/Categories/Categories.xml");

foreach($xml->children() as $Category)
{
  echo "<url><loc>";
  echo "http://www.hittaitorslanda.se/Categories/Category.php?Category=" . $Category->FileName;
  echo "</loc></url>";


  $xmlMembers=simplexml_load_file(getcwd() . "/Members/" . $Category->FileName . ".xml");

  foreach($xmlMembers->children() as $Member)
  {
    echo "<url><loc>";
    echo "http://www.hittaitorslanda.se/Members/Member.php?Category=" . $Category->FileName . "&amp;Member=" . urlencode($Member->Name);
    echo "</loc></url>";
  }

}


echo "</urlset>";
exit;

?>

fredag 20 december 2013

Example on simple menu in html

<!DOCTYPE HTML>
<html>
<head>
<title>menuExample</title>

<style>
.ulNav a {
   text-decoration: none;
   color: black;
   font-size: 11px;
}  
.ulNav a:hover {
   color: whitesmoke;
   background-color: #777777;
}        
.ulNav {
   margin-left: 1px;
   float: left;
}  
.ulNav li
{
   list-style: none;
   margin-right: 0.1em;
   padding: 0 0 0 0;
}  
.ulNav li:hover ul {
   display: block;
   background-color: whitesmoke;
   border: 1px solid black;
}
.ulNav li {
   float: left;
   padding: 0 0.6em;
}    
.ulNav li a, a:hover {
   text-decoration: none;
}  
.ulNav li li {
  float: none;
  margin-left: -44px;
  margin-top: 2px;
}
.ulNavLevel2 {
  display: none;
  position: absolute;  
}
</style>

</head>
<body>
 
   <ul class="ulNav">
     <li>
      <a href="#">Order</a>
      <ul class="ulNavLevel2">
        <li><a href="../Row1.aspx">Row1</a></li>
        <li><a href="../Row2.aspx">Row2</a></li>
        <li><a href="../Row3.aspx">Row3</a></li>
      </ul>
    </li>    
   
    <li>
      <a href="../Customer.aspx">Customer</a>
    </li>
  </ul>


</body>
</html>

tisdag 10 september 2013

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Problem:
System.Security.SecurityException:
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.IO.FileSystemInfo.get_FullName()
at OfficeOpenXml.ExcelPackage.Save()
at OfficeOpenXml.ExcelPackage.SaveAs(FileInfo file)
at ExcelOnTheWebBusiness.CreateExcelFile.ExcelFile.SaveAsExcelFile(DataTable result, DataTable fileNameinExcelFile, DataTable filter, String fileName, String sheetName, Boolean includeFreezePane, Boolean compressFile, ExcelPropertiesData excelPropertiesData)
in C:\Projects\SEGOT-VLCApplications\ExcelOnTheWeb\Development\ExcelOnTheWebBusiness\CreateExcelFile\CreateExcelFile.cs:line 567
at ExcelOnTheWebBusiness.CreateExcelFile.ExcelFile.Create(CreateExcelInputData createExcelInputData, ExcelPropertiesData excelPropertiesData)
in C:\Projects\SEGOT-VLCApplications\ExcelOnTheWeb\Development\ExcelOnTheWebBusiness\CreateExcelFile\CreateExcelFile.cs:line 140

The action that failed was:
Demand

The type of the first permission that failed was:
System.Security.Permissions.FileIOPermission

The first permission that failed was:
The demand was for:
The granted set of the failing assembly was:
The assembly or AppDomain that failed was:
EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1

The method that caused the failure was:
Void Save()

The Zone of the assembly that failed was:
Internet

The Url of the assembly that failed was:
file:///D:/APPS/eow.gto.volvo.net/WebRoot/bin/EPPlus.DLL


Was solved by:Click on button Unblock on the properties window for the file in question:









söndag 11 augusti 2013

Please have a look at my new application, Sök en Site (Search A Site):  http://www.sokensite.netne.net

Also this application is written in Swedish.

It is also written in PHP which is completly new for me!

måndag 5 augusti 2013

An error has occurred for task xxx. Error Message: The following error was reported: 2147943785


Got the following error:



Corrected by:

Start->Administrative Tools -> Local Security Policy
Select Local Policies -> User Rights Assignment
Double click on Log on as a batch job
Click on button Add User or Group...
Enter user id


tisdag 9 juli 2013

Miss the Directory Browser Icon in IIS7 (Windows 2008 R2)

The Direcory Browser Icon was missing on a new Windows 2008 R2 Server:



This was fixed via:
Server Manager - > Select Roles -> Web Server (IIS)
Scroll down to Role Services
Click:  Add Role Services
Check Directory Browsing under Common HTTP Features


tisdag 7 maj 2013

MyBenefitsWiki

Please have a look at my new application, MyBenefitsWiki: https://sites.google.com/site/mybeniftswiki/
It is written in Swedish.

tisdag 29 januari 2013

Visual Studio extremely slow

I had problem with one application that was extremely slow, when working in Visual Studio (2008).
It was in such a state that I had to upgrade my hardware (new much faster PC) to be able to work at all. And even in this new environment it was painfully slow. While working in all other applications worked very smoothly.

At last I found the reason:
The application have two projects that contains the "business logic".

In both projects there was references set up to several COM-components (used to communicate with a mainframe system). Where in one of those projects these components never had been used.

In a major change in the application most of these COM-components was replaced by another solution, and they was removed from the system.
But: the references was only removed from the project where they had been used. In the other project, where they never had been used, they where not removed.

And it was due to this that the performence when working in VS2008 was a disaster. After removing the references it worked ok.

onsdag 16 januari 2013

asp.net datakey does not work sometimes

Had problems reading data from DataKeys in my GridView, for example:

GridViewDistributionHoldRVI.DataKeys[GridViewDistributionHoldRVI.EditIndex][
"DistributionOrderId"].ToString();Returned null.


The problem araised after a time, when developing this function.
The problem was cauesed by that somtimes the value for a Key before the one I tried to read had a value of null, the the values after this could also not be read.

In my example DORInstanceId was null:

DataKeyNames
="DORInstanceId,DistributionOrderId,MainType,ChassisNo,BusinessAreaCode,DistributionPriority,VehicleIdNo,StockCode,BlockCode,HoldDate"

Initiating this value to blank solved this problem.

måndag 10 september 2012

Check that nummber of elements in Enum for the gridcells is the same as actuall number of cells in the gridview.

// Check that nummber of elements in Enum for the gridcells is the same as actuall number of cells in the gridview.
if (Enum.GetValues(typeof(GridCells)).Length != GridViewData.Columns.Count)

{

      throw new Exception("Number of elements in enum GridCells differs from number of cells in GridViewData");

}

tisdag 22 maj 2012

Set focus on textbox in panel handled by CollapsiblePanelExtender

    </asp:Panel>
        <script type="text/javascript" language="javascript">
        //
        //  This part is done because that setting focus in code behind with someting like SetFocusOnControl(TextBoxQualifier)
        //  for some reson does not work when the text box is placed in a Panel that is handled by a CollapsiblePanelExtender.
        //
        //  Also for some reason it does not work to set focus direct in the pageLoad function (but it does work if a alert statement is done after it)
        //  thats why the setFocus function is called from setTimeout.
        //
        var objExtender;
        function pageLoad(sender, args) {
            objExtender = $find("<% =CollapsiblePanelExtender1.ClientID %>");
            objExtender.add_expandComplete(setFocus);
            objExtender.add_collapseComplete(setFocus);           
            setTimeout("setFocus()", 10);
        }
        function setFocus() {
            if (!objExtender.get_Collapsed()) {
                $get("<%=TextBoxQualifier.ClientID%>").focus();
            }
        }  
    </script>

tisdag 17 april 2012

Parser Error Message: The configSource file 'Caching.config' is also used in a parent, this is not allowed.

This error occured in IIS6, Windows 2003.
We solved this by changing the Path for the root-web site to point to another folder than the folder that contains the web-site.
This could be done since nobody uses this root web site.


Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The configSource file 'Caching.config' is also used in a parent, this is not allowed.
Source Error:

Line 27:         Links to other config files.
Line 28:     -->
Line 29:   <cachingConfiguration configSource="Caching.config"/>
Line 30:   <policyInjection configSource="Policy.config"/>
Line 31:   <loggingConfiguration configSource="Logging.config"/>

Source File: D:\Dna\Apps\A4D\a4d-test.vlc.volvo.net\web.config    Line: 29

Show Additional Configuration Errors:

The configSource file 'Policy.config' is also used in a parent, this is not allowed.  (D:\Dna\Apps\A4D\a4d-test.vlc.volvo.net\web.config line 30)
The configSource file 'Logging.config' is also used in a parent, this is not allowed.  (D:\Dna\Apps\A4D\a4d-test.vlc.volvo.net\web.config line 31)
The configSource file 'Unity.config' is also used in a parent, this is not allowed.  (D:\Dna\Apps\A4D\a4d-test.vlc.volvo.net\web.config line 32)
The configSource file 'Exception.config' is also used in a parent, this is not allowed.  (D:\Dna\Apps\A4D\a4d-test.vlc.volvo.net\web.config line 33)
                     


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3625; ASP.NET Version:2.0.50727.3634

måndag 19 mars 2012

Index and length must refer to a location within the string. Parameter name: length

The below error was caused by that Language in the web browser was set to Hungarian (hu-HU).
This problem was resolved by hardcode the culture setting on the MaskedEditExtender object.
In this case it was set to Swedish (SV-SE)

<cc1:MaskedEditExtender ID="maskeditTime" runat="server" TargetControlID="TextBoxTime" MaskType="Time" Mask="99:99" ClearMaskOnLostFocus="false" CultureName="sv-SE"/>

The error print:

Index and length must refer to a location within the string.
Parameter name: length
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
Stack Trace:

[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
   System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +7495179
   System.String.Substring(Int32 startIndex, Int32 length) +11
   AjaxControlToolkit.MaskedEditExtender.OnLoad(EventArgs e) +785
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3625; ASP.NET Version:2.0.50727.3634

måndag 27 februari 2012

Viewstate availability

Maybe it is obvious, but not for me, but:
Viewstate is not accessable from Page_Init, it is accessable first in Page_Load.

Even worse, a ViewState set in Page_Init is available as long the current "instance" is running, but after a post back it is not available anymore.

fredag 24 februari 2012

OWC11 adding an comma sign after some values

For some reason, and just in the Production environment, if you in the Excel object enter a value that is equal to or greater than 2097152, and is equally dividable with 16, gets an comma sign (,) after the value.

That the problems happens with values from 2097152 has something to do with the length of the value when converting it to binary representation,
up to this value the representation is by 21 bits, but from 2097152 it is represented by 22 bits.

I have no idea why this error occurs, and why just in Production environment.
I have uninstalled Excel from our Development environment, and installed the OWC component, so the environment should be identical with Production, but in this environment this problem does not occur.

To get around this problem I only have the following suggestions:
  • Add an character, for example 'X' before or after the value
  • check for commas when reading data from the Excel object, and remove them.
  • Avoid these numbers.

tisdag 7 februari 2012

Uncompress files in Windows XP

To uncompress all files, from current folder and below, type:
compact /u /s /a /q /i *.*
in a CMD-window.