0
檢索數據。當我運行下面的代碼我收到錯誤如何從Access數據庫
沒有爲一個或多個必需的參數給定值。
任何人都可以提出爲什麼可能是?
namespace ATMPROJECT
{
public partial class pin : Form
{
public pin()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection con= new OleDbConnection();
OleDbCommand cmd;
DataSet ds;
OleDbDataAdapter da;
OleDbDataReader dr = null;
string i;
con = new OleDbConnection ("Provider = Microsoft.ACE.OLEDB.12.0; Data Source =C:\\Users\\RELIABLE TRADING CO\\Documents\\atm.accdb ");
con.Open();
if (textBox1.Text == "")
{
label1.Text = ("PLZ ENTER YOUR PIN FIRST");
}
else
{
ds = new DataSet();
i = @"SELECT * from atm WHERE pin= ?";
cmd = new OleDbCommand(i,con);
cmd.Parameters.Add("@pin",OleDbType.VarChar).Value = textBox1 .Text;
da = new OleDbDataAdapter(cmd);
MessageBox.Show("done");
da.Fill(ds);
dataGridView1.DataSource = ds;
// generates error (No value given for one or more required parameters.)