I have a projest has Database And Store Variables.I want to store all values and columns in database and access again , but when i try to access im giving only last value in database.How can i fix this ?
public class Variables
{
public static readonly List<Dictionary<string, string>> rows = new List<Dictionary<string, string>>();
public static Dictionary<string, string> column;
public static String Name = null;
public static String Surname = null;
public static String Gsm = null;
public static String QRCodeID = null;
public static String Email = null;
public static String indirimOrani = null;
}
public class SelectSave()
{
var cmdSelectSave = new SqlCommand
{
CommandText =
"SELECT Name,Surname,Gsm,QRCodeID,Email,indirimOrani FROM elmacustomers WHERE OnayID=1",
CommandType = CommandType.Text,
Connection = sqlConElmaCafePlus
};
SqlDataReader reader = null;
reader = cmdSelectSave.ExecuteReader();
while (reader.Read())
{
Variables.column = new Dictionary<string, string>
{
["Name"] = reader["Name"].ToString(),
["Surname"] = reader["Surname"].ToString(),
["Gsm"] = reader["Gsm"].ToString(),
["QRCodeID"] = reader["QRCodeID"].ToString(),
["Email"] = reader["Email"].ToString(),
["indirimOrani"] = reader["indirimOrani"].ToString()
};
Variables.rows.Add(Variables.column);
}
}
public void DataReceive()
{
foreach (Dictionary<string, string> column in Variables.rows)
{
MessageBox.Show(Variables.column["Name"]);//That's giving only last Name value in database. I want to scan all names in database.
}
}