I have a sqlite database, I make a request to it in the method, and I can’t figure out how to correctly return the delimited string.
public string GetImportedFileList(string connstring, string idrecord,string tablename,string Idname) { string ImportedFiles = null; using (SQLiteConnection connect = new SQLiteConnection(connstring)) { connect.Open(); using (SQLiteCommand fmd = connect.CreateCommand()) { var sb= new StringBuilder(); var que = sb.Append("SELECT * FROM "+tablename+" where "+Idname+"="+idrecord); fmd.CommandText = que.ToString(); fmd.CommandType = CommandType.Text; SQLiteDataReader r = fmd.ExecuteReader(); while (r.Read()) { object[] values = new object[] { }; r.GetValues(values); ImportedFiles= String.Join(",", values).ToString(); } } } return ImportedFiles; }
To the input of the method I submit a connection string, the name of the table, the name of the field I need, and the value of this field. And at the output I want to see the result of the query as a string with a separator.
The string will always be the same, since id is unique in the database. I want to get in the row the values of all columns separated by a comma or another separator.