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;
using System.Data.OleDb;
namespace ProjectOCJB
{
public partial class Form5 : Form
{
private OleDbConnection myCon;
public Form5()
{
myCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|ForeignWorkerinfo.accdb");
InitializeComponent();
}
private void Form5_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'foreignWorkerinfoDataSet.FWinFO' table. You can move, or remove it, as needed.
this.fWinFOTableAdapter.Fill(this.foreignWorkerinfoDataSet.FWinFO);
}
private void button1_Click(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = myCon;
cmd = new OleDbCommand("INSERT INTO [FWinFO] ([ID], [Name], [Gender], [Date of Birth], [Country], [Date of Expire], [Passport No], [Working Place]) VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
cmd.Parameters.AddWithValue("@id", textBox8.Text);
cmd.Parameters.AddWithValue("@name", textBox1.Text);
cmd.Parameters.AddWithValue("@gender", textBox2.Text);
cmd.Parameters.AddWithValue("@dob", dateTimePicker1.Value);
cmd.Parameters.AddWithValue("@country", textBox4.Text);
cmd.Parameters.AddWithValue("@doe", dateTimePicker2.Value);
cmd.Parameters.AddWithValue("@passport", textBox6.Text);
cmd.Parameters.AddWithValue("@workplace", textBox7.Text);
cmd.ExecuteNonQuery();
myCon.Close();
}
}
}
I get this error. anyone could help me?
I was using visual studio 2010 c#.
1. Added datasource

New Topic/Question
Reply



MultiQuote





|