|
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 = string.Empty;
string vpulsecalltaskid = string.Empty;
string LoggingDate = DateTime.Now.ToString();
try
{
logdate = Convert.ToDateTime(record[0]).ToShortDateString();
dealership = record[1].ToString();
salesperson = record[2].ToString();
customername = record[3].ToString();
try
{
homephone = record[4].ToString();
//homephone.Replace("-", "");
}
catch
{
homephone = "Bad format";
}
businessphone = record[5].ToString();
product = record[6].ToString();
comments = record[7].ToString().Replace("
", " ");
//***Get Sales Stage
sellstage = record[8].ToString();
switch(sellstage.ToLower())
{
case "greet":
sellstage = "1";
break;
case "probe":
sellstage = "2";
break;
case "identify machine":
sellstage = "3";
break;
case "presentation":
sellstage = "4";
break;
case "sit down":
sellstage = "5";
break;
case "write up":
sellstage = "6";
break;
case "close the deal":
sellstage = "7";
break;
case "finance":
sellstage = "8";
break;
case "deliver":
sellstage = "9";
break;
default:
if (sellstage.ToLower().IndexOf("service") == -1 && sellstage.ToLower().IndexOf("parts") == -1)
sellstage = "1";
else
sellstage = sellstage;
break;
}
//***Get Sales Stage
vpulsecalltaskid = record[9].ToString();
//Import lead record
SqlCommand command = this.GetCommand();
command.CommandText = @"INSERT INTO CallLogs
(LogDate,
VPulseCallTaskId,
CallLogTypeId,
DealerId,
SalesPerson,
CustomerName,
CustomerHomePhone,
CustomerBusinessPhone,
Product,
Comments,
SaleStage,
LogProcessFlag,
CSI14Days,
CSI17Months,
CSI14DaysProcessFlag,
CSI17MonthsProcessFlag)
VALUES
(@LogDate,
@VPulseCallTaskId,
@CallLogTypeId,
@DealerId,
@SalesPerson,
@CustomerName,
@CustomerHomePhone,
@CustomerBusinessPhone,
@Product,
@Comments,
@SaleStage,
@LogProcessFlag,
@CSI14Days,
@CSI17Months,
@CSI14DaysProcessFlag,
@CSI17MonthsProcessFlag)";
command.Parameters.Add("@LogDate", logdate);
command.Parameters.Add("@VPulseCallTaskId", vpulsecalltaskid);
if ((sellstage.ToLower().IndexOf("service") == -1)&&(sellstage.ToLower().IndexOf("parts") == -1))
{
command.Parameters.Add("@CallLogTypeId", "1");
}
else
{
if (sellstage.ToLower().IndexOf("service") != -1)
{
command.Parameters.Add("@CallLogTypeId", "1"); //Service (4)
dealership = dealership+"_SERVICE";
sellstage = "1";
}
else if (sellstage.ToLower().IndexOf("parts") != -1)
{
command.Parameters.Add("@CallLogTypeId", "1"); //Parts (3)
dealership = dealership+"_PARTS";
sellstage = "1";
}
}
command.Parameters.Add("@DealerId", dealership);
command.Parameters.Add("@SalesPerson", salesperson);
command.Parameters.Add("@CustomerName", customername);
command.Parameters.Add("@CustomerHomePhone", homephone);
command.Parameters.Add("@CustomerBusinessPhone", businessphone);
command.Parameters.Add("@Product", product);
command.Parameters.Add("@Comments", comments);
command.Parameters.Add("@SaleStage", sellstage);
command.Parameters.Add("@LogProcessFlag", false);
command.Parameters.Add("@CSI14Days", Convert.ToDateTime(logdate).AddDays(14).ToString());
command.Parameters.Add("@CSI17Months", Convert.ToDateTime(logdate).AddMonths(17).ToString());
command.Parameters.Add("@CSI14DaysProcessFlag", false);
command.Parameters.Add("@CSI17MonthsProcessFlag", false);
command.ExecuteNonQuery();
this.DisposeCommand(command);
}
catch (Exception exc)
{
string errorText = exc.ToString();
System.Diagnostics.EventLog.WriteEntry("Alliance Level 2 DataRetreiver", errorText);
}
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
Is it possible to get sound data from the microphone? Everyone keeps telling me to go for SAPI, but I'm not doing speech recognition. I'm looking for a way to get data like the sound data in a .WAV file. I need to get the sound, like the Sound Recorder program that comes with Windows. Any suggestions?
Hippophobia - Fear of horses. What?
|
|
|
|
|
DirectX is what you need
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well I guess Direct X shall do the trick!!
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
|
|
|
|
|
can i design a botton in c# like circle or 3D botton or other effects
|
|
|
|
|
There are articles on this site for doing that.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
yes of course you simply need to override the button's Onpaint method to your desired shape, for more information alot of articles regarding this are found on the web and codeproject!
(Tip: Next time search google first)
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
|
|
|
|
|
hi friends
i have two textbox and one context menu strip for both of them that in this menu strip i have an item that show the text of the textbox.
my problem is that in the click event of the context menu strip i dont know that on the witch one of two textbox right click and click on special item occurs.
how can i understand it.
please help me
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
You have to save the source control name when you are showing the context menu in variable and use that value to proceed the context menu command.
Best Regards,
Chetan Patel
|
|
|
|
|
Handle the opening event of the context menu strip and examine the sender parameter.
|
|
|
|
|
In my Gridview rowUpdating event, am not able to retrieve e.NewValues.
e.NewValues and e.OldValues everything returns empty.
Can you please help?
Thanks.
|
|
|
|
|
Hello,
I am trying to write text to a doc with text underlined.I am using Streamwriter to write the text.
Please let me know how do I set the font style to underlined/bold etc. I tried FontStyle, it didnt work.
I tried
sw.WriteLine(strLines[0],FontStyle.Underline);
also
TextMetrics tm = new TextMetrics();
tm.Underlined = true;
tm.Italic = true;
sw.WriteLine(strLines[0],tm);
I cldnt try with TextDecorations work in my project.
Any help wld be appreciated.
Thanks
|
|
|
|
|
Streamwriter writes out text to a target - you can specify encoding for it but it doesn't write out the font stuff - just text.
Now, if you had your text in a RichTextBox, you could save the contents to an RTF file using the SaveFile() method.
I'm sure if I'm incorrect here, someone will step in and let me know.
Good luck.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
Hello Matthew,
I have the text in a wordpad and I have to write it back to the file.
Appreciate your help!
D
|
|
|
|
|
Which is the best way to store a dataset over a page?
Session, Cache or Viewstate?
Thanks
|
|
|
|
|
its obviousely that cache is better to other because session or viewstate has limited and access to them is not suitable for large data
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
Hi,
I am creating a custom web browser. For that I need to make a custom search function. The problem is that I am unable to create text ranges from framed pages such as wikipedia articles. The code is as follows. I would appreciate any help:
//function to find a given string in the page
public int findString(string wordToFind, int myIndex)
{
MSHTML.IHTMLDocument2 htmldom = (MSHTML.IHTMLDocument2)wBrowser.Document.DomDocument;
IHTMLElement outerMostElement;
IHTMLDocument2 doc = (IHTMLDocument2)wBrowser.Document.DomDocument;
if (wBrowser.Document.Body.Parent.ClientRectangle.IsEmpty) {
outerMostElement = doc.body;
}
else {
outerMostElement = doc.body.parentElement;
}
//Create the range
MSHTML.IHTMLTxtRange range1 = MSHTML.IHTMLTxtRange)((MSHTML.IHTMLBodyElement)outerMostElement).createTextRange();
//CType(htmldom.selection.createRange(), MSHTML.IHTMLTxtRange)
//Get the initial start point of the text range
if (range1.text.Substring(myIndex).IndexOf(wordToFind) != -1) {
myIndex = range1.text.Substring(myIndex).IndexOf(wordToFind) + myIndex;
range1.moveStart("character", myIndex);
frmSearch.Hide();
this.Activate();
range1.findText(wordToFind, 0, 0);
range1.select();
//set the start position of the range for te next try
myIndex += wordToFind.Length;
range1.collapse();
return myIndex;
}
else {
return -1;
}
}
Ahmad
|
|
|
|
|
Hi All. I am trying to use process.start but I am getting a file not found exception.
Here is the code - I broke it down to try and find out where the error was:
<br />
strArgs = DateTime.Now.AddMonths(-1).ToShortDateString();<br />
strArgs = strArgs.PadLeft(10,'0');<br />
strArgs = strArgs.Remove(2,4);<br />
file = file.PadLeft(2,'0');<br />
strArgs = " d:\\EOM\\EOM" + file + strArgs + ".ZIP";<br />
path = " d:\\eom\\" + file + "\\*.m*";<br />
strArgs = strArgs + path;<br />
strArgs = "c:\\Progra~1\\Winzip\\wzzip.exe " + strArgs; <br />
myProcess.StartInfo.FileName = strArgs; <br />
myProcess.StartInfo.CreateNoWindow = true;<br />
try<br />
{<br />
blTest = myProcess.Start();<br />
}<br />
catch (SystemException caught)<br />
{<br />
Console.WriteLine(caught.ToString());<br />
}<br />
The strArgs = @"c:\Progra~1\Winzip\wzzip.exe d:\EOM\EOM01082007.ZIP d:\eom\01\*.m*"
from the debugger. If I copy the string from the debugger into the run box of windows, it runs fine.
What am I missing?
Jude
|
|
|
|
|
You are passing in the short path name here which is a convenience for running from the command line. This is a hangover from the old days when you could only have 8 characters in a filename or directory name. You need to replace this with c:\\program files\\winzip\\ and so on.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanx for the quick reply, but that's where I started. I changed it to see if that could have been a problem.
Jude
|
|
|
|
|
I could use this:
Process.Start("c:\\Program Files\\Winzip\\wzzip.exe ",strArgs)
Which works, but I come into a problem there. This code is going through a loop. It executes the line x many times then continues on with the next line of coe. The next line of code uses the files names just created. One small problem - the processes have not finished yet so therefore the is no file names to work with.
Is there a way to check if the process started by Process.Start is finished before moving on to the next one?
Jude
|
|
|
|
|