Wierd error
-
I inherited a program that takes data from a csv file and inserts it into a database. The data is in the following format: 8/20/2007 12:14:21 PM,HDFM,"Nick Yockell","Nate Wittrock",239-850-3931,239-850-2514,"Used 2004 Harley Davidson ","bought bike CUSTOMER WANTS TO BRING HIS YAMAHA R6 IN TO TRADE AND SEE HOW MUCH PAYMENTS WOULD BE. ",Deliver,aa32ed31-f0c8-4f43-a7d4-830d9f29edcd For some reason the function that saves the data to the database is having a problem with the customer phone number (5th column). The database column is a varchar(50) - the same as the customer business phone number. If the customer home phone contains anything other that digits it cannot be saved to the database. However, the customer business phone can contain anything and gets saved just fine. Is there anything in the two functions that could be causing this ? private void ProcessFile(string filename, string vendor) { string path = string.Empty; string LoggingDate = DateTime.Now.ToString(); switch (vendor.ToLower()) { case "vpulse": path = DIRECTORYPATHVPULSE; break; case "calllogpro": path = DIRECTORYPATHCALLLOGPRO; break; } try { OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path+"\\"+";Extended Properties=\"Text;HDR=No;FMT=Delimited()\""); //OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+this.txtSource.Text+"\\"+";Extended Properties=\"Text;HDR=No;\""); OleDbCommand ExcelCommand = new OleDbCommand(@"SELECT * FROM "+filename,ExcelConnection); OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand); ExcelConnection.Open(); DataSet ExcelDataSet = new DataSet(); ExcelAdapter.Fill(ExcelDataSet); ExcelConnection.Close(); //Process File ProcessFileRecords(ExcelDataSet, vendor.ToLower()); //Email Copy to Alliance Group this.EmailFile(path, filename, vendor); } catch (Exception exc) { string errorText = exc.ToString(); System.Diagnostics.EventLog.WriteEntry("Alliance Level 2 DataRetreiver", errorText); } finally { //Archive Copy this.ArchiveFile(path, filename); } } private void ProcessFileRecordVPulse(object[] record) { string logdate = string.Empty; string dealership = string.Empty; string salesperson = string.Empty; string customername = string.Empty; string homephone = string.Empty; string businessphone = string.Empty; string product = string.Empty; string comments = string.Empty; string sellstage = s
-
I inherited a program that takes data from a csv file and inserts it into a database. The data is in the following format: 8/20/2007 12:14:21 PM,HDFM,"Nick Yockell","Nate Wittrock",239-850-3931,239-850-2514,"Used 2004 Harley Davidson ","bought bike CUSTOMER WANTS TO BRING HIS YAMAHA R6 IN TO TRADE AND SEE HOW MUCH PAYMENTS WOULD BE. ",Deliver,aa32ed31-f0c8-4f43-a7d4-830d9f29edcd For some reason the function that saves the data to the database is having a problem with the customer phone number (5th column). The database column is a varchar(50) - the same as the customer business phone number. If the customer home phone contains anything other that digits it cannot be saved to the database. However, the customer business phone can contain anything and gets saved just fine. Is there anything in the two functions that could be causing this ? private void ProcessFile(string filename, string vendor) { string path = string.Empty; string LoggingDate = DateTime.Now.ToString(); switch (vendor.ToLower()) { case "vpulse": path = DIRECTORYPATHVPULSE; break; case "calllogpro": path = DIRECTORYPATHCALLLOGPRO; break; } try { OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path+"\\"+";Extended Properties=\"Text;HDR=No;FMT=Delimited()\""); //OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+this.txtSource.Text+"\\"+";Extended Properties=\"Text;HDR=No;\""); OleDbCommand ExcelCommand = new OleDbCommand(@"SELECT * FROM "+filename,ExcelConnection); OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand); ExcelConnection.Open(); DataSet ExcelDataSet = new DataSet(); ExcelAdapter.Fill(ExcelDataSet); ExcelConnection.Close(); //Process File ProcessFileRecords(ExcelDataSet, vendor.ToLower()); //Email Copy to Alliance Group this.EmailFile(path, filename, vendor); } catch (Exception exc) { string errorText = exc.ToString(); System.Diagnostics.EventLog.WriteEntry("Alliance Level 2 DataRetreiver", errorText); } finally { //Archive Copy this.ArchiveFile(path, filename); } } private void ProcessFileRecordVPulse(object[] record) { string logdate = string.Empty; string dealership = string.Empty; string salesperson = string.Empty; string customername = string.Empty; string homephone = string.Empty; string businessphone = string.Empty; string product = string.Empty; string comments = string.Empty; string sellstage = s
I had read your code, i think it works can you give me the error. In above code there is no error.
Best Regards, Chetan Patel
-
I had read your code, i think it works can you give me the error. In above code there is no error.
Best Regards, Chetan Patel
-
If the customer home phone contains anything other that digits it cannot be saved to the database. Thanks, Nathan
digsy_ wrote:
phone contains anything other that digits it cannot be saved to the database
Shouldn't you then have the phone numbers wrapped around quotations as well? Seems like most of your other fields are.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
digsy_ wrote:
phone contains anything other that digits it cannot be saved to the database
Shouldn't you then have the phone numbers wrapped around quotations as well? Seems like most of your other fields are.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon