 |
|
 |
I would like the first column to be a string and the rest to be floats, but it only displays them as integers
Can anyone point me in the right direction.
Thanks
|
|
|
|
 |
|
 |
I have a 280 rows CSV file, i downloaded the demo program and i execuded it (FinalCSVReader.exe) and it worked just fine. I have strings, integers, doubles, two decimal places when needed, nulls... they look just fine.
Good luck!
Thanks alot for this Mukund!!
|
|
|
|
 |
|
 |
While Inserting the data rows and columns cannot be with in the loop. Row should be outside column loop.
|
|
|
|
 |
|
 |
how to format colum before i run a query..
i have a colum which have value 00100900120070209105914020391232, but after i run query, the colum became 1.00900120070209105914020391232E+32.
i want to display it original value...
how to do it...
i have wrote a .ini file :
s2 = "ColNameHeader=True"
s3 = "Format=" & strFormat
s4 = "MaxScanRows=0"
s5 = "CharacterSet=OEM"
's5 = "CharacterSet=ANSI"
s6 = "Col1=Field1 Char Width 20"
s7 = "Col2=Field2 Char Width 4"
s8 = "Col3=Field3 Char Width 32"
Please Help me
|
|
|
|
 |
|
 |
I need to make the srno number a unique id. When I import I want this the to increment up.
Any help would be greatly appreciated
|
|
|
|
 |
|
 |
I have a CSV file that is formatted like this;
08/09/2007 00:00:06,022.514.054,Ardmore South,OK,1,6040,External 0 Alarm On
Note that the first Comma Delimiter is between the 06 and 022. The import routine is setting the space between the 2007 and the 00: as a delimited field. I only want the Comma as the delimiter. Any idea why it is doing this?
|
|
|
|
 |
|
 |
I tried implementing this, reading and csv-file, but I get some odd behaviour, it only
works on 2003 Server, on windows xp I only get the first column !?! ..my head is empty
can somebody help ..please
pierre
|
|
|
|
 |
|
 |
Please help me.
I use ODBC connection and Dataset among your soucecode.
But any string containing numeric is recognized decimal type.
example) SK30 -> 30.0000 (broken)
sk30 -> sk30 (normal)
Relation Source code.
------------------------------------------------------
# region Function For Importing Data From CSV File
public DataSet ConnectCSV(string filetable)
{
DataSet ds = new DataSet();
try
{
// You can get connected to driver either by using DSN or connection string
// Create a connection string as below, if you want to use DSN less connection. The DBQ attribute sets the path of directory which contains CSV files
string strConnString="Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="+txtCSVFolderPath.Text.Trim()+";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string sql_select;
System.Data.Odbc.OdbcConnection conn;
//Create connection to CSV file
conn = new System.Data.Odbc.OdbcConnection(strConnString.Trim());
// For creating a connection using DSN, use following line
//conn = new System.Data.Odbc.OdbcConnection(DSN="MyDSN");
//Open the connection
conn.Open();
//Fetch records from CSV
sql_select = "select * from ["+ filetable +"]";
obj_oledb_da = new System.Data.Odbc.OdbcDataAdapter(sql_select,conn);
//Fill dataset with the records from CSV file
obj_oledb_da.Fill(ds,"Stocks");
//Set the datagrid properties
dGridCSVdata.DataSource=ds;
dGridCSVdata.DataMember="Stocks";
//Close Connection to CSV file
conn.Close();
}
catch(Exception e) //Error
{
MessageBox.Show(e.Message);
}
return ds;
}
---------------------------------------------------------------------------------------------
text type :
2050762;1111111111115;abc;abcde@HANMAIL.NET;;;abc;469-884;abc;20051212;20070703;SK30;Flip Chip;Flip Chip Team;abd;;;;;Y;;;
2050762;1111111111115;abc;abcde@HANMAIL.NET;;;abc;469-884;abc;20051212;20070703;SK30;Flip Chip;Flip Chip Team;abd;;;;;Y;;;
In this sentence, sk30 --> 30.0000
How to solve it ?
GYseven
gy7choi@gmail.com
|
|
|
|
 |
|
 |
Hi,
Is there anyway for us to check whether the CSV file content is applying the scheme defined in schema.ini file or not?
|
|
|
|
 |
|
 |
hi,
I am developing a project where there is a need of importing a CSV file to database. As i have no idea about C# i am not able to understand ur C# code.
So can you plese tell me how to import the data using VB.NET.
Thank u...
Jats
|
|
|
|
 |
|
 |
If I am taking delimitor for the csv file as single quote (') then how hould I put it as delemitor in my connection string. When I am importing the file.
Thank you,
Regards,
Aleem.
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
 |
|
 |
Hello,
My problem is that i don't want to import the strings between some special characters, i want to import the whole text from a .txt or .doc file. How can i do that?
Thanks.
Sare
|
|
|
|
 |
|
 |
There are enough examples given in MSDN to do this. You may also get it on other sites. You need simple IO operation here. still I am giving you a sample code from MSDN:
The following code example shows a simple way to read text from a text file.
using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
}
|
|
|
|
 |
|
 |
I have a CSV file with 15 columns in it. I know the sample project was setup for just 2 columns. I am only getting 2 columns of data showing. If I edit the 14 in this line...for (int j = 1; j <= da.Tables["Stocks"].Columns.Count - 14; j++) to 13 I gain an additional column of data but the rows duplicate once. As I decrease the 14 one by one, each number I decrease by is how many duplicates of the rows I get. Can someone help me out on this?
// Now we will collect data from data table and insert it into database one by one
// Initially there will be no data in database so we will insert data in first two columns
// and after that we will update data in same row for remaining columns
// The logic is simple. 'i' represents rows while 'j' represents columns
cmd.Connection = con1;
cmd.CommandType = CommandType.Text;
cmd1.Connection = con1;
cmd1.CommandType = CommandType.Text;
con1.Open();
for (int i = 0; i <= da.Tables["Stocks"].Rows.Count - 1; i++)
{
for (int j = 1; j <= da.Tables["Stocks"].Columns.Count - 14; j++)
{
cmd.CommandText = "Insert into Test (srno, " + da.Tables["Stocks"].Columns[0].ColumnName.Trim() + ") values(" + (i + 1) + ",'" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(0) + "')";
// For UPDATE statement, in where clause you need some unique row
//identifier. We are using ‘srno’ in WHERE clause.
cmd1.CommandText = "Update Test set " + da.Tables["Stocks"].Columns[j].ColumnName.Trim() + " = '" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(j) + "' where srno =" + (i + 1);
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
}
}
Thanks,
JMO
-- modified at 9:33 Monday 22nd January, 2007
|
|
|
|
 |
|
 |
Move the following lines before the inner loop:
cmd.CommandText = "Insert into Test (srno, " + da.Tables["Stocks"].Columns[0].ColumnName.Trim() + ") values(" + (i + 1) + ",'" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(0) + "')";
cmd.ExecuteNonQuery();
It was trying to insert 15 rows (i.e. the number of columns).
BTW: You should probably look at using a parametorized SQLCommand. If there are any single-quotes in your CSV data then it will cause an error in your current code.
Regards
Andy
|
|
|
|
 |
|
 |
Thanks for your quick answer, that did fix that particular problem.
How would I set a parameterized SQLCommand? My code is erroring out on line 436 because of a quotation mark.
This is what I have now.
sql_select = "select * from ["+ filetable +"]";
Thanks,
JMO
|
|
|
|
 |
|
 |
Hi,
This code Geeting all column Data Into DataBase.
cmd.Connection = con1;
cmd.CommandType = CommandType.Text;
cmd1.Connection = con1;
cmd1.CommandType = CommandType.Text;
con1.Open();
for (int i = 0; i <= da.Tables["Stocks"].Rows.Count - 1; i++)
{
for (int j = 1; j <= da.Tables["Stocks"].Columns.Count - 14; j++)
{
if(j==0){
cmd.CommandText = "Insert into Test (srno, " + da.Tables["Stocks"].Columns[0].ColumnName.Trim() + ") values(" + (i + 1) + ",'" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(0) + "')";
cmd.ExecuteNonQuery();
}
else {
// For UPDATE statement, in where clause you need some unique row
//identifier. We are using ‘srno’ in WHERE clause.
cmd1.CommandText = "Update Test set " + da.Tables["Stocks"].Columns[j].ColumnName.Trim() + " = '" + da.Tables["Stocks"].Rows[i].ItemArray.GetValue(j) + "' where srno =" + (i + 1);
cmd1.ExecuteNonQuery();
}
}
}
|
|
|
|
 |
|
 |
HI,
this is good code but when i m trying to open connection with odbc i m getting an error msg like "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". please solve my problem ....
thanks in advance
|
|
|
|
 |
|
 |
This is because, fupCsvFile.FileName will give u only the filename. Try using fupCsvFile.PostedFile.FileName where fupCsvFile is the nama of the FileUploader control .Now fupCsvFile.PostedFile.FileName will give u the filename with file path.
Pls try this.
Nishanth Nair
|
|
|
|
 |
|
 |
I solved this problem by changing the connection string
Driver={Microsoft Text Driver (*.txt;*.csv)};
to
Driver={Microsoft Text-Treiber (*.txt; *.csv)};
if you have a look in the BDE Administrator console in Control Panel, under the Configuration tab, you'll find the list of the drivers you can use. just pick the correct one
|
|
|
|
 |
|
 |
jadejonge wrote: solved this problem by changing the connection string
Driver={Microsoft Text Driver (*.txt;*.csv)};
to
Driver={Microsoft Text-Treiber (*.txt; *.csv)};
Note that ODBC driver names need to be specified exactly as they are named; I had exactly the same error as you and found that I was also missing a space after the semicolon in the extension list; ie you need:
Driver={Microsoft Text Driver (*.txt; *.csv)}; (right)
rather than:
Driver={Microsoft Text Driver (*.txt;*.csv)}; (wrong)
Hope this helps others!
Timshel Knoll-Miller
|
|
|
|
 |
|
 |
Hi,
Thank you so much for your program I used it and it works perfectly. The only doubt is that when I run DBI executable in order to generate the conString.txt file I get a warning message saying "Could not find a part of the path "D:\". I know you have mentioned that the .CSV file has to be in the D drive but is there a way to change the path from D drive to a C drive, I don't have a D drive in my PC all I have is a C drive.
I'll be looking forward to hear from you very soon....
Thanks in advance,
Sam Khanjar
Developer Engineer
|
|
|
|
 |
|
 |
Hi Mukund,
This is a nice app that I could learn from. Could you also please provide the connection string text file to the SQLServer?
Thanks,
Sekhar
Sekhar
|
|
|
|
 |
|
 |
Hi ..
It was really a nice work done by you. But there is a little problem with it.
my CSV file column names contains. dot "." i.e. First.Name and while import the csv to datatable these dots are converting into "#" so it becomes like First#Name.
Hope you can figure it out.
Regars / Xkaliber
|
|
|
|
 |
|
 |
Hi,
good work...but...
connstring.txt...
is not in project...
why??
Please...can i build this file...
Thnkx
Gvt
|
|
|
|
 |