<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8260084\x26blogName\x3dInspirone\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://inspirone.blogspot.com/search\x26blogLocale\x3den_GB\x26v\x3d2\x26homepageUrl\x3dhttp://inspirone.blogspot.com/\x26vt\x3d5304759022731441925', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>


"I maintain that Truth is a pathless land, and you cannot approach it by any path whatsoever, by any religion, by any sect. Truth, being limitless, unconditioned, unapproachable by any path whatsoever, cannot be organized; nor should any organization be formed to lead or to coerce people along any particular path. You must climb towards the Truth. It cannot be 'stepped down' or organized for you." - author: Jiddu Krishnamurthi

Saturday, January 27, 2007

Mine Apollo

I've always been an adept of fast food and fast cooking foods, these can be very helpful when you lead a hectic or lonely life. I like to experiment recipes with ready to cook or semi cooked packed/canned stuffs. My thinking is simple in terms of food, complex things take time to prepare and by time you prepare it you no longer want to eat it. Its better allow others to cook these for you. So less time you spend in the kitchen the more time you have to appreciate your meal ;) Here's a blog that might turn out interesting:
Happy eating!!!

Tuesday, January 09, 2007

Loading images dynamically in Crystal Report

Having come across a few issues related to the above I thought it might be worth to post the solution here so as to share it with other delvelopers.

Visual Studio 2003/2005 does not readily allow you to load an image file on a Crystal Report dynamically unless you use "Dynamic Image Location" feature which is available in Crystal Reports Developer XI. But there is a cheaper work around for this. The solution is to dynamically add an binary column to the XSD dataset and in the dataset containing the data to be printed. Then load the image file as binary data into the dataset.

1. In a column in your database table store the path to the image that needs to be displayed in a crystal report document, in this example the image path column name is "ImagePath".

2. Create a new Dataset/XML schema(xsd) in VS.Net that maps the fields in the database table. This should be the normal procedure when creating a report. In this XSD DataSet add an additional field that is not in the table and which is of type base64Binary :

xs:element name="Image" type="xs:base64Binary" minOccurs="0"

Note that the opening and closing tags are missing above since it won't be printed on this site. Just add enclose the above in "< />"

3. When designing the report based on this DataSet, drag and drop the "Image" field in the region where you want it to appear.

4. Add the following procedures to your code:

Private Sub AddImageColumn(ByVal objDataTable As DataTable, ByVal strFieldName As String)
'create the column to hold the binary image
Dim objDataColumn As DataColumn = New DataColumn(strFieldName, Type.GetType("System.Byte[]"))
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub

'*... and this one to load the image in the above added field:
Private Sub LoadImage(ByVal objDataRow As DataRow, ByVal strImageField As String, ByVal FilePath As String)
Dim fs As System.IO.FileStream = New System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim Image() As Byte = New Byte(fs.Length) {}
fs.Read(Image, 0, CType(fs.Length, Integer))
objDataRow(strImageField) = Image
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub

5. Before assigning the dataset to the "SetDataSource" of your report, add the following code:

' Fill the dataset "DS" as required with data to be displayed on the report
'* Begin code to add
AddImageColumn(DS.Tables(0), "Image")
' Loop to load the image for each row
For index As Integer = 0 To DS.Tables(0).Rows.Count - 1
If Not String.IsNullOrEmpty(DS.Tables(0).Rows(index).Item("ImagePath").ToString) Then
LoadImage(DS.Tables(0).Rows(index), "Image", _
'* You could load a default image here, like "no image to display"
'* if you have a standard one then un-comment the code below and change the image path
'LoadImage(DS.Tables(0).Rows(index), "Image", "c:\MyDefaultImage.JPG")
End If
'* End code to add
' Display report in a report viewer control

Thursday, January 04, 2007

Deception or surprise

When you desperately wait for something to happen and it does not, deception takes over. But when something nice happens and you were not expecting it, then it is a nice surprise. I prefer to have nice surprises in life rather than deceptions. In spite of having a positive attitude, in most situations I prefer to expect the worst case scenario. Thus if something goes wrong, I have already anticipated for it, otherwise i'm nicely surprised. It's hard to expect the worst though when you start thinking about the benefits that you can get with the good. Thought interferes with ideas, but one needs to control thought and suppress it when required.

How does one feel, when one has no news from someone one cares for? No phone calls, no mails, nothing, just void. It surely is a feeling of frustration, unbearable agony, emptiness, helplessness. Sometimes it happens that a person is so close but still very far away or even unreachable. Is hope a solution? Hope is meaningless and has nothing concrete in it, whereas facts are realistic. One has to be realistic in life and never live on hopes...

Tuesday, January 02, 2007

What's in a number?

Year in year out, the same sequence of events take place. It seems like the whole year, if not a whole life, is a routine and only the number changes. The year changes, one's age, Weight, salary, friends, girlfriend/boyfriend, wife/husband, amount of things one owns etc... the list itself consists of numbers. In one way or the other everything changes in terms of a number. It's strange how numbers and maths are part of our daily life. It seems like a very close relationship, something we can't get away from no matter what we do, numbers pop up everywhere. We are invaded by numbers and that's scary. Numbers can be in your favour or against you depending on which side you are.

Anyways one interesting use of numbers and maths is a little card trick that I learned some time ago, though I can't remember when, from whom or where. The trick is simple but yet very puzzling. Since I probably got it for free I guess its best to share it. Knowledge is not new, it can only be shard across humanity. Therefore everything we learn is old. Even when we come across new knowledge, the moment we realise this, it is already old. Thought being source of knowledge, thought being an action of the past since by the time we react time has already elapsed, we are constantly living in the past. So be it.

Here goes the trick:

Take a complete pack of cards, which consists of 52 cards. In a pile, count out 26 cards with their face up to split the pack into 2. The trick is to memorise the 7th card only. Note: when performed in front of an audience, it is important to keep them distracted so that they don't notice the trick. To do this simply count with a loud voice. Now once done, place the pile face down aside. With the remaining 26 cards, draw one card and lay it face up. Each card bears their respective numeric value and cards with figures have a value of 10 and aces 1. The thing is to add cards on top of the card drawn to make it 10. For instance if the card drawn was 6 add 4 cards face down on top of it, if it is a card that has the value of 10 then no cards should be added. This process should be repeated 3 times such that in the end there should be 3 set of cards arranged down with the first card face up and the remaining cards face down.

Pile 1, Card drawn : 3, No of cards to add on top: 7
Pile 2, Card drawn : Ace, No of cards to add on top: 9
Pile 3, Card drawn : King, No of cards to add on top: 0

Once done, put the remaining cards on top of the 26 card pile that was put aside. From the arranged cards, calculate the sum of the cards that are face up. In the above example the sum should be: 3 + 1 + 10 = 14. From the pile of remaining cards draw a card face down until the sum calculated above is reached. If done properly, the last card counted should be the 7th card memorised at the start of the trick. Amazingly it is a mathematical logic that never fails. No matter which 3 cards are drawn, provided the number of cards drawn add up to 10, their sum would always point to the 7th card in the second pile. Isn't this magic!!!

Labels: , ,