Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Wierd error

Wierd error

Scheduled Pinned Locked Moved C#
helpdatabasebusinesssalesquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    digsy_
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • D digsy_

      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

      C Offline
      C Offline
      Chetan Patel
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • C 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

        D Offline
        D Offline
        digsy_
        wrote on last edited by
        #3

        If the customer home phone contains anything other that digits it cannot be saved to the database. Thanks, Nathan

        P 1 Reply Last reply
        0
        • D digsy_

          If the customer home phone contains anything other that digits it cannot be saved to the database. Thanks, Nathan

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • P Paul Conrad

            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

            D Offline
            D Offline
            digsy_
            wrote on last edited by
            #5

            I'll try that - the next field in the csv row has exactly the same types of data in it and doesnt have any problems being saved to the database

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups