Monday, January 21, 2008

How to use ReplicateString, Replace, Len in Crystal Report

today i would share about coding in crystal report. how to use replicatestring, replace, and len function.
in my example, i would try to display a number "0000001" from recordnumber.

here the step on creating the code:
1. first we must convert the recordnumber from integer into text.
ToText(RecordNumber) --> "1.00"
2. we must hidden or replace ".00" with blank character. we can use replace function
(Replace (ToText(RecordNumber),".00","") --> "1"


3. then we must count the length of result
len(Replace (ToText(RecordNumber),".00","")) --> length = 1
4. we must count how much we would to replicate the character "0"
in this example, i would like display 7 digits.
7-len(Replace (ToText(RecordNumber) --> number to repilcate = 6
5. and then we replicate the character "0"
ReplicateString ("0",7-len(Replace (ToText(RecordNumber),".00",""))) --> "000000"
6. the last step, we concatenate the string with the actual number
ReplicateString ("0",7-len(Replace (ToText(RecordNumber),".00",""))) + Replace (ToText(RecordNumber),".00","") --> "0000001"

if the recordnumber was 987, then the result was: "0000987"

oks, have a nice try.. cu...



| Read More | Join My Community | Grab RSS | Stumble it |

Wednesday, January 16, 2008

Adding Single Qoute in SQL Query

Hi...

I would like to share how to add a single qoute in SQL Query.

example:

DatabaseName = Northwinds
TableName = Employees
FieldName = FirstName

and in the FirstName contain: Layong


we want the result show up when we process: 'Layong

we just need add 4x single qoute, and then the single qoute would show up.

here the simple query that I create:

SELECT '''' + FirstName
FROM Employees
WHERE FirstName = 'Layong'

The result will be:

'Layong

Have a nice try with this knowledge...


| Read More | Join My Community | Grab RSS | Stumble it |
Google

Microsoft News for ADO .NET:

Our Email Address:

blog.programming@gmail.com