hi Dears,
i am very very new in programming and i have a problem with inserting something into table,
this is when i connect it with database iam able to read everything in database,
private OleDbConnection myCon;
public Form1()
{
InitializeComponent();
myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Aidi\Desktop\AccessDBase\WindowsFormsApplication1\WindowsFormsApplication1\Students.mdb");
}
i have create a button for creating a new student which is working good,
private void NewBtn_Click(object sender, EventArgs e)
{
RollnoTb.Text = "";
NameTB.Text = "";
FatherTb.Text = "";
AddressTb.Text = "";
}
but when i want to insert it wont work, this is what i have done so far
private void InsertBtn_Click(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand();
cmd=.CommandType= CommandType.Text;
cmd.CommandText= "insert into StudentInfo[RollNr,Sname,Sfather,Address] Values ['"+ RollnoTb.Text+"','"+NameTB+"','"+ FatherTb.Text+"','"+AddressTb.Text+"'];
cmd.Connection=myCon;
myCon.Open();
cmd.ExecuteNonQuery();
myCon.Close();
}
and need some assistance correcting my code please.