Tuesday, October 30, 2007

"ADO.NET Parameter" usage : Order is matter with OLEDB provider

While we are doing Data Manipulation using ADO.NET, "Parameter" objects for In/Out direction values, specified "Order of Parameters" is matter with OLEDB Provider.

In SQLServer Data Provider, parameters order is NOT a matter, parameters names are important.




For example: From "Emp" table, we need employees with Given Name and Given Salary.
to do this, we need to supply values for two parameters (Name and Salary)

...
...
OLEDBConnection con = new SQLConnection("give connection string here");


string strCommand= "select * from emp where Name=@Name and Salary=@Salary";

OLEDBCommand cmd = new OLEDBCommand(strCommand);
cmd.Connection = con;


OLEDBParameter paramName = new OLEDBParameter( );
paramName.ParameterName ="Name";
paramName.value = "Vignesh";
cmd.parameters.add(paramName);


OLEDBParameter paramSalary = new OLEDBParameter( );
paramSalary.ParameterName ="Salary";
paramSalary.value = "20o00";
cmd.parameters.add(paramSalary);

...
...
...



Here, we are doing with OLEDB Provider. In our example, we added parameter in the same order as in given query. So, it won't create problem.


OLEDB looking for ORDER of parameter, NOT for the parameter name. Check the parameter names given in the Query (they are @Name and @Salary) .


in coding : paramName.ParameterName ="Name"

even you change the parameter name as

   paramName.ParameterName ="NOTName"

It won't be problem, we added that paramName as first in the cmd's parameters collection. so, take care about "order of parameters" while adding to Command object in OLEDB provider.



but in SQLSERVER Provider, parameter name is important, so paramObject.ParameterName must match with Parameter name which is given in the Query.


---

In one of my application, i was affected by this problem [ actually, problem was with me, even i know about OLEDB's behavior in Parameters, i found this issue only after 2 weeks ]

---

for other Data Providers [ Oracle provider and ODBC provider] i will verify and Update soon.

---

Thursday, October 18, 2007

Some of Answers for Popular "23-page puzzle"

Some of Answers for Popular "23-page puzzle"

7 Uranus , 8th Planet neptune
8 Acht, neun for 9 in German
9 Sept, Oct , the short form for the 10th month
10 10 of Spades, the Jack comes next
11 eLeVeN, tWeLvE for 12
12 12 x 12 = 144, 13 x 13 = 169
13 Number13, Number14 for 14
14 Catorce, quince is 15 in Spanish
15 15thPresident of the Us is buchunan, 16th is Lincoln
16 is sedicim, septendecim is 17 in Latin
17 is 10001, 10010 is Binary 18 (old old code)
18 is argon, potassium the next in the periodic table
19 is ojofuffo minus one alphabet to each letter, and twenty minus one you get uxfouz
20 is icosagon - 20 side pentagon, 21 side is icosihenagon
21 is 10946 is a Fibonacci number, and the next is 17711
22 is very simple Vooey, and 23 must be Woody
23 is one crazy grandmother dancing to this long long night