I am trying to access columns dynamically, It works fine when i select two columns, but when i try to elect the third it gives an eror, the C# syntax is as follows,
string connStr = "Server=localhost;Database=db_pentest;Uid=root;Pwd=#901770026V;";
bool found = false;
MySqlConnection conn = new MySqlConnection(connStr);
conn.Open();
MySqlCommand cmd;
cmd = conn.CreateCommand();
cmd.CommandText = "dynamicCols";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new MySqlParameter("@col", "country,IPRStart,IPREnd"));
MySqlDataReader readIp = cmd.ExecuteReader();
The error i get is,
Unknown column 'IPR' in 'field list'
The stored procedure goes something like this,
SET @sql = CONCAT('SELECT ', col, ' FROM ..
where is pass the column names i wan to select to that single col parameter. but it wont let me send more than two.. it cuts off the trailing charters of IPREnd..??
can you please help me on this..i'm doing it in this way because i need to select random columns whenever i want. Thank you very much :)