我有一个在RDB扩展名中的文件。我需要从这个文件中获取数据,以便将数据放入DataTable中。但我不知道如何从RDB文件中读取数据。我在网上没有发现任何信息。
请帮帮我。
祝你今天过得愉快。
发布于 2020-11-17 16:05:33
我将数据作为字符串放入DataTable中。我没有在原始代码中包含任何格式。
public class Lecture
{
public DataTable Lecture_RDB(string databaseName)
{
//Déclarartions des variables
double mem_time, valeur_init;
int ititre, k, l, nbligne;
string entete = ";";
string[] titre = new string[9];
List<string> ligne = new List<string>();
string ecriture = "";
string indicetag = "";
string destination = "";
string mem_titre = "";
DataTable dt = new DataTable();
dt.Columns.Add("Col A", typeof(string));
dt.Columns.Add("Col B", typeof(string));
dt.Columns.Add("Col C", typeof(string));
dt.Columns.Add("Col D", typeof(string));
//Déclarations base de données
SQLite.SQLiteConnection SQLconnect = new SQLite.SQLiteConnection();
SQLiteCommand SQLcommand;
SQLiteDataReader SQLreader;
try
{
//Connexion au fichier RDB
SQLconnect.ConnectionString = "Data Source=" + databaseName + ";";
SQLconnect.Open();
//Creation Requete pour lecture en-tete
SQLcommand = SQLconnect.CreateCommand;
SQLcommand.CommandText = "SELECT * FROM logdata";
//Execution requete
SQLreader = SQLcommand.ExecuteReader();
while (SQLreader.Read())
{
string[] row = SQLreader.Cast<object[]>().Select(x => x.ToString()).ToArray();
dt.Rows.Add(row);
}
}
catch(Exception ex)
{
//Si erreur pendant la lecture du fichier message
Console.WriteLine("Error file reading : {0}.{1} Error", databaseName, ex.Message);
}
return dt;
}
}https://stackoverflow.com/questions/64858785
复制相似问题