Home
Manage Your Code
Snippet: Lettura di u file di testo tramite ODBC (C#)
Title: Lettura di u file di testo tramite ODBC Language: C#
Description: viene sfruttato il supporto per il linguaggio SQL Views: 59
Author: Mauro Migoni Date Added: 1/21/2008
Copy Code  
1				string text = File.ReadAllText(file_name);
2				text = text.Replace("'", "''");
3				File.WriteAllText(file_name, text);
4
5				conn = new OdbcConnection("Provider=MSDASQL;DSN=" + DSN + ";");
6				conn.Open();
7				ds = new DataSet();
8				OdbcDataAdapter adapter = new OdbcDataAdapter();
9				adapter.SelectCommand = new OdbcCommand("SELECT " + ((distinct_clause) ? "DISTINCT" : "") + " * FROM " + file_name + ((where_condition != "" && where_condition != null) ? " WHERE " + where_condition : "") + ((ordering != "" && ordering != null) ? " ORDER BY " + ordering : ""), conn);
10				adapter.Fill(ds);