[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Compare an Input to values in a CSV File

flit

8/28/2006 2:54:00 PM

Hello All,

I am a newbie, trying hard to learn.
My little programm opens a csv file, and try to find if a value entered
in a textbox is present or not in the csv file.
here is my buggy code

this line gives me error on the debug mode:
string valor = reader.GetValue(x).ToString()

The error
"An unhandled exception of type 'System.Data.Odbc.OdbcException'
occurred in system.data.dll"

I am totally lost...if somebody has a better way to check the values on
the csv and just return (ok there is, and the 1st field is...)

string ConnectionString = @"Driver={Microsoft Text Driver (*.txt;
*.csv)};DBQ=c:\";
OdbcConnection connection = new OdbcConnection(ConnectionString);
connection.Open();
OdbcCommand command = new OdbcCommand("Select * FROM saida.txt",
connection);
OdbcDataReader reader = command.ExecuteReader();
string contador;
contador = reader.Depth.ToString();
MessageBox.Show(contador);
while (reader.Read())
{


for (int x = 0; x < reader.FieldCount; x++)
{
string valor = reader.GetValue(x).ToString();
if (textBox1.Text.Equals(valor))
{

// add code for puting fields into array....
MessageBox.Show(reader.GetDataTypeName(x) + " - " +
reader.GetValue(x));
}
}

}