Friday, April 1, 2011

validate large XML file



Recently, I got a requirement to validate a large XML file almost 1000000 lines.

Here is a sample code to do that against

       
class SampleXMLValidation

{

 [STAThread]

 static void Main(string[] args)

 {

  // Read the file.

  XmlTextReader Reader = new XmlTextReader("MyFile.xml");

  XmlValidatingReader validater = new XmlValidatingReader(Reader);
  //Schema Validator

  validater.ValidationType = ValidationType.Schema;

  validater.ValidationEventHandler += new ValidationEventHandler

  (ValidationHandler);

  while (validater.Read());

  Console.WriteLine("Validation was successful...No Errors ");

  Console.Read();

 }

 public static void ValidationHandler(object sender,

 ValidationEventArgs args)

 {

  Console.WriteLine("Validation Error");

  Console.WriteLine("\tSeverity:{0}", args.Severity);

  Console.WriteLine("\tMessage :{0}", args.Message);

  Console.Read();

 }

}

}
       
 

If we want to validate online, Here is a good link for that

Saturday, March 26, 2011

Microsoft Certified Technology Specialist NET Framework 4 Data Access


I'm honoured that I got a certification of Microsoft® Certified Technology Specialist: .NET Framework 4, Data Access.

I have prepared hard for below topics and cleared this exam -
  1. ADO.NET 4 coding techniques and framework components
  2. ADO.NET Data Services LINQ
  3. LINQ to SQL
  4. Entity Framework technologies
  5. Structured Query Language (SQL)
  6. Stored procedures
  7. Database structures/schemas (objects) XML

Friday, February 25, 2011

How to update date filed in Oracle like SQL



Update tableName set date =to_date(‘6/5/2011’,’mm/dd/yyyy’) where ---

A few more options for the update -


UPDATE employees SET
    job_id = 'SA_MAN', salary = salary + 1000, department_id = 120
    WHERE first_name||' '||last_name = 'Douglas Grant';


UPDATE employees a
    SET department_id =
        (SELECT department_id
            FROM departments
            WHERE location_id = '2100'),
        (salary, commission_pct) =
        (SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct)
          FROM employees b
          WHERE a.department_id = b.department_id)
    WHERE department_id IN
        (SELECT department_id
          FROM departments
          WHERE location_id = 2900
              OR location_id = 2700);

UPDATE employees
   SET salary = salary * 1.1
   WHERE department_id = 100
   RETURNING SUM(salary) INTO :bnd1;


UPDATE employees
  SET job_id ='SA_MAN', salary = salary + 1000, department_id = 140
  WHERE last_name = 'Jones'
  RETURNING salary*0.25, last_name, department_id
    INTO :bnd1, :bnd2, :bnd3;

How to get top n Record in Oracle like Sql



Sample Query to get Top n Record from oracle

Select * from tableName where FiledName =”” and rownum<=5

The above statement will give u top 5 record
rownum<=5

A few more queries -

Not in

SELECT 'TRUE' 
    FROM emp 

    WHERE deptno NOT IN (5,15); 


LIKE Operator

SELECT sal 
    FROM emp 

    WHERE ename LIKE 'SM%';

Case Sensitivity and Pattern Matching

UPPER(ename) LIKE 'SM%'

Oracle UNION Example 

SELECT part, partnum, to_date(null) date_in
    FROM orders_list1
UNION
SELECT part, to_null(null), date_in
    FROM orders_list2;

Oracle UNION ALL Example 
Result - SELECT part 
    FROM orders_list1 
UNION ALL 
SELECT part 
    FROM orders_list2;

MINUS Example

SELECT part 
    FROM orders_list1 
MINUS 
SELECT part 
    FROM orders_list2;

INTERSECT  Example
SELECT part 
    FROM orders_list1 
INTERSECT 
SELECT part 

    FROM orders_list2;



Saturday, September 4, 2010

Some Important Operation



Get Item Control Value from server Side
Convert.ToString((DataGrdi.Items[e.Item.ItemIndex].FindControl("hdnfield") as HiddenField).Value);

Get Data Kety Values
Convert.ToString(DataGrid.DataKeys[e.Item.ItemIndex].ToString());

Using Of string.IsNullOrEmpty

Java Script Message From Server Side





Sample code -

string script = string.Format("alert('{0}');", cleanMessage);
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert")) 
{
    page.ClientScript.RegisterClientScriptBlock(page.GetType(), "alert", script, true /* addScriptTags */);
}

Call parent function by User control ( by Reflection Class ) Asp.Net V Imp




Here is a simple command to invoke parent function from the User control

this.Page.GetType().InvokeMember("DisplayMessage", System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { txtMessage.Text });


We need this most of the time when applying the facets at the page level. and the child components need to update the parent one,  As an example below.