我正在为我的C#类编写一个ATM应用程序。它从在线数据库获取其信息。我不断收到几个错误,但我想弄清楚的是Expected类,委托,枚举,接口或结构错误。这是代码的任何想法吗?
namespace ATMapp
{
public partial class Form1 : Form
{
// instance variables used to manipulate database
private Connection myConnection;
private Statement myStatement;
private ResultSet myResultSet;
string databaseURL = "http://www.boehnecamp.com/phpMyAdmin/razorsql_mysql_bridge.php";
// establish connection to database
try
{
// connect to database
SQL sql = new SQL();
myConnection = sql.getConnection(databaseURL);
// create Statement for executing SQL
myStatement = myConnection.createStatement(databaseURL);
}
catch (Exception)
{
Console.WriteLine ("Cannot connect to database server");
}
// close statement and database connection
myStatement.close();
myConnection.close();
// load account numbers to accountNumberJComboBox
private void loadAccountNumbers()
{
// get all account numbers from database
try
{
myResultSet = myStatement.executeQuery("SELECT accountNumber FROM accountInformation");
// add account numbers to accountNumberJComboBox
while ( myResultSet.next() )
{
accountComboBox = accountNumberComboBox.Item.Add(myResultSet.getString( "accountNumber" ) );
//ComboBox accountNumberComboBox = new ComboBox();
}
myResultSet.close(); // close myResultSet
} // end try
catch ( Exception)
{
Console.WriteLine("Error in loadAccountNumbers");
}
} // end method loadAccountNumbers
private void retrieveAccountInformation()
{
// get account information
try
{
myResultSet = myStatement.executeQuery( "SELECT pin, " +
"firstName, balanceAmount FROM accountInformation " +
"WHERE accountNumber = '" + userAccountNumber + "'" );
// get next result
if ( myResultSet.next() )
{
pin = myResultSet.getString( "pin" );
firstName = myResultSet.getString( "firstName" );
balance = myResultSet.getDouble( "balanceAmount" );
}
myResultSet.close(); // close myResultSet
} // end try
catch (Exception)
{
Console.WriteLine("Error in retrieveAccountInformation");
}
} // end method retrieveAccountInformation
// update database after withdrawing
private void updateBalance()
{
// update balance in database
try
{
myStatement.executeUpdate( "UPDATE accountInformation" +
" SET balanceAmount = " + balance + " WHERE " +
"accountNumber = '" + userAccountNumber + "'" );
}
catch (Exception)
{
Console.WriteLine("Error in updateBalance");
}
} // end method updateBalance