Search This Blog


Thursday, January 10, 2013

Missing records in CSV file while importing from DB(C# code)

Yesterday I faced a very strange problem in CSV files the data was mismatching from the db.
I have a small application which is used to pull data from db and write into a flat file csv . In other words its import data from db to CSV file.  All of sudden yesterday user has raised a P1 tickets regarding the data in the csv file is missing some data is not found in the csv my colleague check is that data present in the db or not but in the query result it was available and we find that the record count in the db and csv is miss matching almost 700 records are not present in csv files.  They have done all their effort  but  still they are not able to find out where actually the problem is ? Then it is come to me. And I have started debugging of code and checking every condition very carefully after a couple of hours I find that everything s are fine and record writing in the file is absolutely same.  But still I have open the csv file the records are missing and getting the same value as they are getting. I surprised to see this  then I have change the extension of the csv file to txt and open it with excel now what I see that record count is absolutely fine and matching with db. I surprised in normal cases in csv file data increase but this time data is missing. I made changes in the query and replace all commas with blank space but still the problem is same. I have also made some other changes like changing the delimiter “,” to “|” its solve the issue but I am not able to separate the columns as in excel.  After couple of hourse struggle and analyzing the data carefully I found that in some date there was some  “(double quotes)  and that’s why when in csv file all the data between the “ ”  treated as one record. After remove the “ quotes from data It solved the problem.
Hope my experience may guide you in such kind of problem.
Happy learning

Friday, August 10, 2012 web-service in Ajax 1.0

This article can be used for .net 1.0(Vs2003) to secure webservices which is called on aspx page throgh core AJAX like xmlhttp. in this article no .net ajax component is used but it can be used for .net2.5 and 3.0 2005 and 2008 with a little bit trick which I will give in my next post.
on aspx page.

you have set the header. and call the web service using get method.
hope this help 
if you find any difficulties  please post your comment.
xmlhttp.setRequestHeader('securityTicket' , SECURITY_TICKET );

on aspx.vb page

Private Sub GenerateSecurityTicket()
        Dim cacheKey As String = User.Identity.Name + ":securityTicket"
        Dim securityTicket As String = Guid.NewGuid().ToString()

        Cache(cacheKey) = securityTicket

        Dim script As String = "<script type=""text/javascript"">" + String.Format("SECURITY_TICKET = '{0}';", securityTicket) + "</script>"

        Page.RegisterClientScriptBlock("securityKey", script)
    End Sub

end sub

asmx Page

Private Sub EnsureTicket()
        Dim context As HttpContext = HttpContext.Current

        Dim headerTicket As String = context.Request.Headers("securityTicket")

        If headerTicket Is Nothing Or headerTicket = String.Empty Then
            Throw New System.Exception("Security ticket must be present.")
        End If

        Dim cacheKey As String = context.User.Identity.Name + ":securityTicket"
        Dim cacheTicket As String = DirectCast(context.Cache(cacheKey), String)

        If String.Compare(headerTicket, cacheTicket, False) <> 0 Then
            Throw New System.Exception("Security ticket mismatched.")
        End If
    End Sub

call EnsureTicket()

from every webmethod

Thursday, March 15, 2012

Sohel's Blog: SharePoint 2010: Add/Delete/update/search list ite...

Sohel's Blog: SharePoint 2010: Add/Delete/update/search list ite...: Managed client Object model is a rich extension to SharePoint 2010. You can almost perform all kinds operations against SharePoint using Cli...

Friday, February 24, 2012

Sudoku list generation program in C-sharp

This is really a  very good program , fast and optimize

class Program
        static void Main(string[] args)

            const int n = 3;

            for (int i = 0; i < n * n; i++)
                for (int j = 0; j < n * n; j++)
                    Console.Write((i * n + i / n + j) % (n * n) + 1);
            } Console.ReadLine();

Wednesday, February 22, 2012

Abstract Factory Pattern in .Net with Example (C#)...

Abstract Factory Pattern in .Net with Example (C#)...: Abstract Factory Pattern Abstract Factory pattern is used to create concrete class instances without specifying the exact class type (ie, to...