Hello all!! I am coding a simulated ATM for my software eng class. I would consider myself to be an intermediate programmer, but I have run into a huge problem. I have opened and linked my database to my C# project;
however I can not get the SQL statement "Select FreeChecking from BankAccount where PIN = ..."; to return the value that is saved in the database.
HELP PLEASE! I am attaching snippets of my code
however I can not get the SQL statement "Select FreeChecking from BankAccount where PIN = ..."; to return the value that is saved in the database.
HELP PLEASE! I am attaching snippets of my code
Code:
//--------------------------------------------------------
//This method returns one selected record from database.
//--------------------------------------------------------
public DataTable RecordSelect(String Sql)
{
cmd = new OleDbCommand(Sql, conn);
adapter = new OleDbDataAdapter(Sql, conn);
dt = new DataTable();
adapter.Fill(dt);
return dt;
}
Code:
String sqlText = String.Format("SELECT FreeChecking FROM BankAccount2 where PIN = {0};", PIN);
dt = db.RecordSelect(sqlText);
for (int i = 0; i < atmData.Rows.Count; i++)
{
try
{
string msg = String.Format("{0} {1} {2:c} {3:c}",
atmData.Rows[i]["User"],
atmData.Rows[i]["PIN"],
atmData.Rows[i]["FreeChecking"],
atmData.Rows[i]["PersonalSavings"]);
MessageBox.Show(msg);
}
catch (Exception)
{
}
}
Comment