Getting multiple records from SQL Server database with C# -


can tell me why not working, please? show me first database record matches statement , need display of them match. works except shows first record matches. thank in advance.

using (connection = new sqlconnection(connectionstring)) using (sqldataadapter adapter = new sqldataadapter("select * members month = '" + currentmonth + "' , day = '" + currentday +"'", connection)) {     datatable memberstable = new datatable();     dataset info = new dataset();     adapter.fill(memberstable);     adapter.fill(info);      var rows = info.tables[0].rows;      foreach (datarow row in rows)     {          nameemployee = info.tables[0].rows[0]["name"].tostring();         messagebox.show (nameemployee);     }  } 

see following line:

nameemployee = info.tables[0].rows[0]["name"].tostring(); 

you within foreach loop , have "current" row in row variable. line should read:

nameemployee = row["name"].tostring(); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -