0

I am trying to import a csv file into an SQL sever CE sdf database in a c# mvc3 web app. I understand that I need to read the csv file first and then transfer the file line by line into the sql database. I am very new to programming and need some guidence on how to do this.

I have heard Sql Compact Bulk Copy is the way to go, but I do not understand how to get the CSV file so it can be used by this. If anyone can shed some light on this I would be very greatful.

I hope this makes sense.

Michael
  • 1
  • 1

1 Answers1

0

To create a new sdf File this is a litle example:

// if exists delete the file 

System.IO.File.Delete("Test.sdf");

string cnn = "Data Source = 'TestDB.sdf'; LCID=1033; Password = <ThePassword>;";
SqlCeEngine ceEngine = new SqlCeEngine(cnn);
ceenngine.CreateDatabase();`

If you need to know more details you can read this MSDN(Create a Database by Using the Engine Object) http://msdn.microsoft.com/en-us/library/ms171966.aspx

GeoAvila
  • 146
  • 8