|
Hey everbody
I have a big problem to upload one csv fil to mysql database.
i have a big csv file with many records and column
Eks.:
ArticleNo ManArticleNo DescShort DescLong Manufacturer Price Stock
642 0993A001 BJ-642/black 790sh f BJ300 330 Canon blækpatron, sort (BJI-642BK) Canon 97,11 0
665 1009A001 BJC-643/black f BJC-800 820 880 Canon blækpatron, sort (BJI-643BK) Canon 157,43 0
673 1012A001 BJC-643/yellow f BJC-800 820 880 Canon blækpatron, gul (BJI-643Y) Canon 203,42 0
3131 51604A HP Ink Cart/Black f ThJet QJet+ f plain HP blækpatron, sort (CJ-3A) Hewlett Packard 57,91 115
3135 51605R HP Ink cart/red f Think- Quietjet HP blækpatron til ThinkJet/QuietJet, magenta Hewlett Packard 63,63 0
i load the file like this
StreamReader input = new StreamReader(@"c:\test.csv");
string inputLine = "";
while ((inputLine = input.ReadLine()) != null)
{
but now i need just to take ManArticleNo and Price from the inputLine
my input line has all the row, how can i split or somthing to take just that column i need ?
string tr = inputLine.?(?);
}
input.Close();
|
|
|
|
|
string[] columns = inputLine.Split(',');
then you just reference the index of the columns you want e.g.
string ManArticleNo = columns[0];
then you do the database update stuff
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
you are the man
|
|
|
|
|
hi,
I have created Excel-RTD server in C#. like this article
http://weblogs.asp.net/kennykerr/archive/2008/11/13/Rtd3.aspx[^]
Here data is populating randomly in excel file.
I will start RTD Server from different project (like button clik) :- able to start successfully
and i want to send/update data to rtd server from other project. :- object used by RTD sever has no value, it is worked altogether in different thread.
Thanks
hiren shah
hirenkshah@gmail.com
|
|
|
|
|
That's great.
Regards,
Rob Philpott.
|
|
|
|
|
Hi,
I have a data grid control and I placed one combo box in that data grid and I am binding data to data grid combo box.When i run the application by default the combo box is not showing anything if i double click on combo box then only it is displaying the items. Can anybody please help me to resolve the problem showing combo box items in data grid control by default when i run the application.
Thanks in Advance
Pavani
|
|
|
|
|
Hi, I want to give a value in a textbox when the 'tab' key is pressed in another textbox. My code is this:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ( (e.KeyChar.Equals(('\t'))) || (e.KeyChar.Equals(Keys.Tab)) ){
this.textBox2.Text = "hola";
}
}
But the only way that it works is to set the 'Multiline' and 'AcceptsTab' properties to be true (both properties at the same time, unless it not works). And the problem is that on this way, to press the tab key the focus not change to another textbox.
Anybody knows a better way?
|
|
|
|
|
Why not use the Leave or Validated event for this ?
|
|
|
|
|
It is a good alternative. I can use the keyPress event for the intro key, and the Leave event for the tab key.
Ok, thanks
|
|
|
|
|
2869 is the error code which is shown while installing the service setup .The service is working good in XP.
is there any thing which i should add while creating service to run in vista
|
|
|
|
|
dont know the error code but when i had a vista issue, it was to do with the project manifest, maybe you could look at that. Its to do with trusting the application or something
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
thanks
but what is this project manifest
|
|
|
|
|
something to do with security, somes vista apps seem to want it to run. Its somesort of xml coded file that determines how the application should run, i.e. as administrator or user etc.
I cant remember in detail have a look at this or search c# manifest or something
http://support.microsoft.com/kb/944276[^]
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Hi CP,
I am desiging a custom control combobox that looks like combobox at design time in VS 2005 .
I am left with one thing. I dont want to use dropdownstyle but i want the user cannot write any text at runtime in the combobox. i suppressed the combobox & removed the caret.'
ReQ : i want the user cannot write anything in the combobox if the caret is not preset also.
Regards
vb8.0
|
|
|
|
|
Sonds like a disaster. Why have a combobox at all ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi Graus ,
Thanks for responding.This is for the end user.
I am creating a custom ComboBox which doesnt accept the caret , text and doesn't show the list .
Now i required is how to hide the focus when the cursor is on the combobox button to show as disable.
1 ) how to hide the focus when the cursor is on the combobox button at runtime ?
Any ideas ?
Any views regarding this ?
Regards,
VB 8.0
|
|
|
|
|
VB 8.0 wrote: a custom ComboBox which doesnt accept the caret , text and doesn't show the list .
You mean a 'Label'???
My opinion is... If someone has already posted an answer, dont post the SAME answer
|
|
|
|
|
Why on earth would you want to design a combobox with no dropdown?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I hate it when people respond with "WHY DO YOU WANT TO DO THAT?"
The OP asked HOW, not WHY!!! Regardless of your reasoning!
|
|
|
|
|
I've heard of being a dollar short and a day late but you're 14 months late and I'm definitely a dollar short.
Not that it matters now but the reason that I asked why was so that I could get a better handle on what the OP was really trying to do, the better to formulate a sensible reply.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello everybody
First sorry my english but i need som help.
I have a website where i sal computer and other stof, every day i get i xls. file from one company with price list model number, description and other thing.
Every product in my website has parnumber: thats unik.
So i want to make a function in c# to update the price in mysql database because the price changes every day.
How can i make a function like update table_name from c:\test.xls (take just price and partnumber from xls file ) where partnumber=(partnumber from xls) ?
I hope really much you can help me.
|
|
|
|
|
You will need to write code to parse the Excel file ( either export as csv, or use the Office interop stuff ), then write your SQL.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks
but do you have som code in c# i can use ?
|
|
|
|
|
Not really, no. Connecting to a db is trivial, and widely documented. Parsing a CSV is trivial, use File.ReadAllLines and the Split method on the string class to break each line into discreet items. Controlling Excel is also well documented.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Burim,
I had written an app to import excel files. That was some 3 years ago, so I no longer have the code.
I did a google search for "C# import excel file into sql" and I found the same link I had used to write the code some 3 years ago. The link:
http://davidhayden.com/blog/dave/archive/2006/05/31/2976.aspx[^]
I recommend you use this link to do the following:
1) SQLBulkImport the Excel file into an import table (a table in the same database but that is only used for this purpose)
2) Call stored procedure that grabs the needed data from the import table and updates whatever table(s) you need to update.
In my case, I had a Unique partNumber, too, so I would
A) Mark records in my primary table as "inactive" (I use a tinyint with 1=inactive and 2=active) that were no longer in the import table
B) Add new records from the import table into the primary table.
C) Update records in the primary table with changed values in the import table (usually the description and price).
Hope this helps.
ASP ~ Apple Simply Performs
|
|
|
|