Add the following code in the textBox_KeyPress event:
If (Not Char.IsNumber(e.KeyChar) And (e.KeyChar <> ChrW(Keys.Back))) Then
e.Handled = True
End If
Most of the posts in this blog are based on real time issues and scenarios. The main goal here is to share userful information and help many people out there. These information are really used and working. Please share any information you have while reading this blog.
Tuesday, June 19, 2012
Column Names in upper case for Oracle subquery
Oracle is case-insensitive for table and column names in queries but the data
dictionary records names in uppercase.
check out this example below:
select User_Number, User_Description from (
select user_id as "User_Number", User_name as "User_Description" from users_tbl);
The above query returns error as below:
ORA-00904: "USER_DESCRIPTION": invalid identifier
00904. 00000 - "%s: invalid identifier"
Corrected query:
select USER_NUMBER, USER_DECSRIPTION from (
select user_id as "USER_NUMBER", User_name as "USER_DECSRIPTION" from users_tbl);
check out this example below:
select User_Number, User_Description from (
select user_id as "User_Number", User_name as "User_Description" from users_tbl);
The above query returns error as below:
ORA-00904: "USER_DESCRIPTION": invalid identifier
00904. 00000 - "%s: invalid identifier"
Corrected query:
select USER_NUMBER, USER_DECSRIPTION from (
select user_id as "USER_NUMBER", User_name as "USER_DECSRIPTION" from users_tbl);
Monday, June 11, 2012
Loose Coupling - Good Discussion
http://forums.asp.net/t/944241.aspx/1?Loose+%20coupling
A good article on Interfaces
http://dotnet.dzone.com/articles/c-interfaces-what-are-they-and
Friday, June 8, 2012
Same parameters used multiples times in Oracle Query
If we use same parameters multiple times in a query in oracle as shown in example, it errors out. We need to create another set of variables with same values.
Check the usage of parameters in the below example:
:fromDate
:toDate
:uname
:fromDate1
:toDate1
:uname1
:fromDate2
:toDate2
:uname2
All the above paramaters are having the same values.
select user_name,call_reason from call_mrs_tbl, users_tbl where call_placed_dt between :fromdate and :toDate
and user_name = :uname order by user_description
select user_name,call_reason from call_tbl, users_tbl where call_placed_dt between :fromdate and :toDate
and user_name = :uname order by user_description;
Check the usage of parameters in the below example:
:fromDate
:toDate
:uname
:fromDate1
:toDate1
:uname1
:fromDate2
:toDate2
:uname2
All the above paramaters are having the same values.
For example:-
select user_name,call_reason from call_tbl, users_tbl where call_placed_dt between :fromdate and :toDate
and user_name = :uname order by user_description
FULL JOIN
select user_name,call_reason from call_mrs_tbl, users_tbl where call_placed_dt between :fromdate1 and :toDate1
and user_name = :uname1 order by user_description
FULL JOIN
select user_name,call_reason from call_tbl, users_tbl where call_placed_dt between :fromdate2 and :toDate2
and user_name = :uname2 order by user_description;
We cannot use the above query as below. It errors out saying invalid datatype.
select user_name,call_reason from call_tbl, users_tbl where call_placed_dt between :fromdate and :toDate
and user_name = :uname order by user_description
FULL JOIN
and user_name = :uname order by user_description
FULL JOIN
and user_name = :uname order by user_description;
Order of parameters matters in oracle query
Faced lots of time to figure out why my oracle query was erroring out. It was the order of the dynamic parameters in the query should match the order we pass the parameter with values.
For example:-
select user_name,call_reason from call_tbl, users_tbl where call_placed_dt between :fromdate and :toDate
and user_name = :uname order by user_description;
Here you can see three parameters :fromDate, :toDate & :uname. These parameters needs to be passed from C# using command object in the following order in which it is used in the query, which is as below:
1. :fromDate
2. :toDate
3. :uname
I was passing the parameters in the following order:
1. :uname
2. :fromDate
3. :toDate
Took me a while to figure out. These are some tips which can be used if you stumble across such error again, you need not waste much time to figure out.
Hope this helps others.
For example:-
select user_name,call_reason from call_tbl, users_tbl where call_placed_dt between :fromdate and :toDate
and user_name = :uname order by user_description;
Here you can see three parameters :fromDate, :toDate & :uname. These parameters needs to be passed from C# using command object in the following order in which it is used in the query, which is as below:
1. :fromDate
2. :toDate
3. :uname
I was passing the parameters in the following order:
1. :uname
2. :fromDate
3. :toDate
Took me a while to figure out. These are some tips which can be used if you stumble across such error again, you need not waste much time to figure out.
Hope this helps others.
Subscribe to:
Posts (Atom)