i really need an urgent help, stuck with writing cod to import csv file with double quote into sql server database, can someone help me am a newbie in programming
uploading csv fileuploading csv file with double quote to sql server database
Page 1 of 1
6 Replies - 1177 Views - Last Post: 04 September 2010 - 12:58 AM
Replies To: uploading csv file
#2
Re: uploading csv file
Posted 29 August 2010 - 10:33 PM
If you're using Microsoft Sql Server, there's the data import tool. There's no programming required. You just have to map the file correctly to the correct columns.
#3
Re: uploading csv file
Posted 31 August 2010 - 06:44 PM
I have use some of the tools like ssis, bulk insert, openrowset and they all give me errors resuling from the double quote complication in the CSv file. can u help me with codes to overcome the double quote and import the fie to sql server database
#4
Re: uploading csv file
Posted 31 August 2010 - 06:47 PM
Moved to Databases.
Note no one's likely to hand you code, if that's what you're expecting.
Note no one's likely to hand you code, if that's what you're expecting.
#5
Re: uploading csv file
Posted 01 September 2010 - 05:03 PM
The below is my code..can some one help me figure out why i cant upload the csv file;thanks
MOD EDIT: When posting code...USE CODE TAGS!!!
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileInfo fileinfo = new FileInfo(FileUpload1.PostedFile.FileName);
string strCsvFilePath = Server.MapPath("CSVFolder") + "\\" + fileinfo.Name;
FileUpload1.SaveAs(strCsvFilePath);
string strFilePath = Server.MapPath("CSVFolder");
//DataTable csvTable = new DataTable("CSV_Data");
SqlConnection dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ToString());
StreamReader sr = new StreamReader(strCsvFilePath);
string csvDataconnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strCsvFilePath + ";"
+ "Extended Properties=" + "'text;HDR=Yes;FMT=Delimited'";
{
OleDbConnection con = new OleDbConnection(csvDataconnectionString);
OleDbCommand cmd = new OleDbCommand(string.Format
("SELECT * FROM [{0}]", strFilePath), con);
con.Open();
// Using a DataReader to process the data
OleDbDataReader reader = cmd.ExecuteReader();
SqlBulkCopy bc = new SqlBulkCopy(dbConn);
bc.DestinationTableName = "CSV_Data";
//bc.BatchSize = csvTable.Rows.Count;
dbConn.Open();
while (reader.Read())
{
bc.WriteToServer(reader);
}
dbConn.Close();
bc.Close();
}
}
}
}
}
MOD EDIT: When posting code...USE CODE TAGS!!!
This post has been edited by JackOfAllTrades: 03 September 2010 - 04:38 AM
Reason for edit:: Added code tags
#6
Re: uploading csv file
Posted 03 September 2010 - 04:40 AM
OK, now we have code, so I guess I'll move this to C#.
Please tell us what exactly is the problem you are having...any errors? How does the result differ from what you expect?
Please tell us what exactly is the problem you are having...any errors? How does the result differ from what you expect?
#7
Re: uploading csv file
Posted 04 September 2010 - 12:58 AM
Quote
they all give me errors resuling from the double quote complication in the CSv file
Can you give an example of such complication? Can you attach the CSV file?
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|