I am having trouble with my login and receive this warning

'noOfRows = da.Fill(ds, "tblCustomers");'

No value given for one or more required parameters.

I want My Login to search my database for the correct pin and account number but my program doesnt seem to work.

My code for form1 is '

' using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;'





namespace HNC_BANK_ATM_PROJECT



public partial class FormWelcome : Form
{
    public static int tTimesUsed = 0;
    public static Decimal TotalBalance = 0; // for summary stats
    public static decimal EuroRate;
    public static System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
    public static FormWelcome Welcome = new FormWelcome();
    public static string euro; //for euroo pickup
    public static decimal eurorate = 0; // for euro exchange 
    string dbProvider;
    string dbSource;
    int noOfRows;

    string sql;
    System.Data.OleDb.OleDbDataAdapter da; //Used to retrieve data from a data source and fill tables

    DataSet ds = new DataSet();// DataSet used to stor many data tables in a single collection





    public FormWelcome()
    {
        InitializeComponent();
    }



    private void btncontinue_Click(object sender, EventArgs e)
    {
        Form FrmLogin = new FrmLogin();
        tTimesUsed += 1;
        this.Hide();
        FrmLogin.Show();
    }



    private void FormWelcome_Load(object sender, EventArgs e)
    {
        int count = 0;
        dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;";// This is the database provider

        dbSource = "Data Source = 'D:banking.accdb'";// this is where my database is held

        con.ConnectionString = dbProvider + dbSource;

        ds = new DataSet();
        con.Open();

        sql = "SELECT tblCustomers.* FROM tblCustomers";

        da = new System.Data.OleDb.OleDbDataAdapter(sql, con);
        noOfRows = da.Fill(ds, "tblCustomers"); //the da is being used to fill my dataset with my customer table

        con.Close();

        EuroRate = Convert.ToDecimal(ds.Tables["tblCustomers"].Rows[0][4]);

        System.Data.OleDb.OleDbCommandBuilder cb = new System.Data.OleDb.OleDbCommandBuilder(da);




        for (count = 1; count <= noOfRows - 1; count++)
        {


            ds.Tables["tblCustomers"].Rows[count][4] = 0;
            TotalBalance = TotalBalance + Convert.ToDecimal(ds.Tables["tblCustomers"].Rows[count][3]);

       }

             da.Update(ds, "tblCustomers");


    }
}


}'


My code for form 2 is

'using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HNC_BANK_ATM_PROJECT
{
    public partial class FrmLogin : Form
    {
        public static System.Data.OleDb.OleDbDataAdapter da;
        public static DataSet ds = new DataSet();



    public static string Account;
    public static string Pin;
    public static int Payments;
    public static string Surname;

    public static string Balance;
    public static bool authenticated;

    public static int tFailedLogins = 0;
    public static int tCardsRetained = 0;
    public static string tWithdraw = "0";

    int noOfRows;

    string sql;



    public FrmLogin()
    {
        InitializeComponent();
    }

    private void btnLogin_Click(object sender, EventArgs e)
    {
        this.DialogResult = System.Windows.Forms.DialogResult.OK;
        authenticated = checkAuthentication();
        if (authenticated == false)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            MessageBox.Show("Card has been Retained Please Contact Your Branch");

            this.Close();
            FormWelcome.Welcome.Show();

        }

        if (authenticated == true)
        {

            Surname = ds.Tables["tblCustomers"].Rows[0][2].ToString();
            Account = ds.Tables["tblCustomers"].Rows[0][4].ToString();
            Balance = ds.Tables["tblCustomers"].Rows[0][6].ToString();

            FrmTransaction Transaction = new FrmTransaction();
            this.Close();
            Transaction.Show();

            txtAccount.Text = "11111111";
            txtPin.Text = "9999";
        }
        }

    private bool checkAuthentication()
    {
        string targetPin = null;

        ds = new DataSet();
        FormWelcome.con.Open();

        sql = "SELECT tblCustomers.* FROM tblCustomers WHERE ((tblCustomers.Account) = '" + txtAccount.Text + "')";

        da = new System.Data.OleDb.OleDbDataAdapter(sql, FormWelcome.con);
        noOfRows = da.Fill(ds, "tblCustomers");

        FormWelcome.con.Close();

        if (noOfRows != 1) //checks if account number is on database
        {

            MessageBox.Show("Account Number is Not Recognised.\r\n");
            return false;

        }

        else
        {

            targetPin = ds.Tables["tblCustomers"].Rows[0][5].ToString();//checks the column to find a matching pin

            if (targetPin == txtPin.Text)
            {
                Account = txtAccount.Text;
                Pin = txtPin.Text;
                return true;

            }
            else
            {


                MessageBox.Show("Pin is Not recognised.\r\n");
                return false;

            }
        }
    }


    private void btnExit_Click(object sender, EventArgs e)
    {
        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        this.Close();
        FormWelcome.Welcome.Show();
    }

    private void FrmLogin_Load(object sender, EventArgs e)
    {
        txtAccount.Clear();
        txtPin.Clear();
    }}}'



    My database is in the order As follows forename surname address accountno pin balance today withdraw

    Any help would be much appreciated

noOfRows = da.Fill(ds, "tblCustomers");
No value given for one or more required parameters.

Documentation is amazing. There's no overload that takes just a DataSet and a string.

This article has been dead for over six months. Start a new discussion instead.