1
Answer

problems with an account exercise

vor

vor

20y
1.5k
1
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Data.OleDb; namespace bankcontact { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { public OleDbConnection DB=new OleDbConnection("Provider=Microsoft.Jet.OleDB.4.0;Data Source=" + Application.StartupPath + "/Winkel.mdb"); ==> private void cmdKlik_Click(object sender, System.EventArgs e) { string Naampje=cmbNaam.Text; string Codetje=txtCode.Text; ArrayList Naam=new ArrayList(); ArrayList Code=new ArrayList(); DB.Open(); OleDbCommand rsNaam=new OleDbCommand("SELECT Naam FROM tblGebruiker ORDER BY GebruikerId",DB); OleDbDataReader rdNaam = rsNaam.ExecuteReader(); while(rdNaam.Read()) { Naam.Add(rdNaam.GetString(0)); } rdNaam.Close(); DB.Close(); DB.Open(); OleDbCommand rsCode=new OleDbCommand("SELECT Code FROM tblGebruiker ORDER BY GebruikerId",DB); OleDbDataReader rdCode = rsCode.ExecuteReader(); while(rdNaam.Read()) { Code.Add(rdCode.GetString(0)); } rdCode.Close(); DB.Close(); foreach (object o in Naam) { if (o.ToString().ToLower()==Naampje.ToLower()) { foreach (object a in Code) { if (a.ToString().ToLower()==Codetje.ToLower()) { MessageBox.Show("Test"); } } } } } private void Form1_Load(object sender, System.EventArgs e) { DB.Open(); OleDbDataAdapter daNaam=new OleDbDataAdapter("Select GebruikerId,Naam from tblGebruiker",DB); DataSet dsNaam=new DataSet(); daNaam.TableMappings.Add("Table","Gebruiker"); daNaam.Fill(dsNaam); DataColumn colNaam=dsNaam.Tables["Gebruiker"].Columns["GebruikerId"]; cmbNaam.DisplayMember="Gebruiker.Naam"; cmbNaam.ValueMember="Gebruiker.GebruikerId"; cmbNaam.DataSource=dsNaam; } } the meaning of the programm is that when you insert the right name and code into the 2 tekstboxes you'll be able to withdraw money from you account. you can only withdraw 1000€ per day. you have to type the amount of money that you want to withdraw in a third tekstbox. when the money is taken, there wil come a tekstbox with the money that is left on you account. (startmoney is 1000€, this is put into the database.) this is the code for the control of the code and the usersname. but when i run the program there is a break on: OleDbCommand rsNaam=new OleDbCommand("SELECT Naam FROM tblGebruiker ORDER BY GebruikerId",DB); i really dont know the solution. can anybody help me??? thx
Answers (1)
Next Recommended Forum