Start New Discussion within our Software Development Community

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.

hi everybody,

now i solve the previous problem now i am able to store the data into the table but in the second row name SName i am getting this meesage System.Windows.Forms.TextBox, Text: plus my input

need a help please i am a new C# user

This question has already been answered. Start a new discussion instead.