I have a program where logged in users can upload/dowload files. I want a query when a user is logged in, and store the data in an array. Here's my code:
string query = "SELECT * FROM Login;";
var valami = new DataTable();
var con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Roland\Desktop\IBCONTROLL\BIZT.MENTÉS\program_1.7\db_connect_ver_1\login.mdf;Integrated Security=True");
var sda = new SqlDataAdapter(query, con);
sda.Fill(valami);
var result = new string[valami.Columns.Count];
DataRow dr = valami.Rows[1];
for (var i = 0; i < dr.ItemArray.Length; i++)
{
result[i] = dr[i].ToString();
}
foreach (var t in result)
{
Console.WriteLine(t);
}
The problem is that this is making an 1 dimension array, but I need a two dimension array, and use it later just as a table.
Can you please help me fix this code?