Skip to content

Adding csv file to database

Asked Dec 16, 2008, 3:39 AM EST6 answers
Share
LinkedInX
Hai all.....

I have a tcp dump file a darpa intrusion detection data set....I opened it thru a tool called Wireshark and i could see the columns as No,Time,Source ip,Destination ip,Protocol,Info......

Using this tool i converted the .tcpdump file int Comma seperated value(CSV) file...

My goal is to add the data set into sql server database....

when i wrote the c# code to add a csv file into database it showing an error called the file is not present in the directory....but actually the csv file is there but in unrecognized format...How do i rectify it...

Help me please.....

6 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    Ok, I have a question do you want to stock it as a binary file as a blob file or you want that each column of the given file is stored in  a given data base column?
    0
  • 0
    Thanks for the reply man....

    I dont know much about blob data type....and which one is easier n preferable to do....anyway i go for the last...adding the stock to each individual data column.....
    0
  • Bechir Bejaoui
    0
    Ok, then could you please give me the exact form of your CSV file, you can present it with false data, I want just to see it so that I can give you the right code
    About stocking/retrieving a Blob file to/from a data base I suggest this Amr's article
    0
  • 0
    Hai man.............

    Thanks for the reply......anyway how can i post a file in this forum to show the csv file which i am working in.......

    Thanks...
    0
  • 0

    Have you stored the tcpdump into a database??

    If yes, Please explain how?

    How do you convert tcpdump to csv data?

    Thanks.

    0
  • 0
    Hai man...

    I have successfully added the dump file into my database....wat i did was

    first i opened the dump file using Wireshark tool then i stored it as .csv file..hope this not a prob for u...

    Then in c# i used the following code...

    SqlCommand command = new SqlCommand();
        command.Connection = con;
        command.CommandText = "BULK INSERT snort.dbo.[IncomingDataset]" + @" FROM 'c:\wednesday'" + "WITH" + "(" + "FIELDTERMINATOR = ','," + "ROWTERMINATOR='\n'" + ")";
        command.CommandTimeout = 300;
        command.ExecuteNonQuery();
        Console.WriteLine("--------Dataset loaded sucessfully-------\n\n"); 

    stored in sql server 2005
    Here snort.dbo is the database name
    Incomingdataset is the table name

    c:/wednesday is the csv file.....


    Hope i made myself clear..any doubt lemme know...
    0