none
SYNTAX ERROR INSERT INTO STATEMENT PLEASE HELP , HERE.S THE CODE RRS feed

  • General discussion

  • oleDbCmd.Connection = Database5Conn;
                Database5Conn.Open();
                oleDbCmd.CommandText = "INSERT INTO" + this.textBox2.Text + "( [subject],[location],[start]) values('" + this.textBox3 + "' , '" + this.textBox4 + "' , '" + this.textBox5 + "');"; //,'"+ this.textBox2.Text + "' + '" + this.textBox3.Text + "');
                oleDbCmd.ExecuteNonQuery();
                Database5Conn.Close();  

    FULL CODE 

    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 WindowsFormsApplication1
    {
        public partial class Form1 : Form
        { public OleDbConnection Database5Conn;
            public OleDbCommand oleDbCmd = new OleDbCommand();
            public String connParam = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\mc\Documents\Database27.accdb;Persist Security Info=False";
            public Form1()
            {
                Database5Conn = new OleDbConnection(connParam);
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {

            }

            private void button1_Click(object sender, EventArgs e)
            {
                string a = this.textBox1.Text.Replace(@".", "");
                
                textBox2.AppendText(a);
            }

            private void button2_Click(object sender, EventArgs e)
            {
                oleDbCmd.Connection = Database5Conn;
                Database5Conn.Open();
                oleDbCmd.CommandText = "INSERT INTO" + this.textBox2.Text + "( [subject],[location],[start]) values('" + this.textBox3 + "' , '" + this.textBox4 + "' , '" + this.textBox5 + "');"; //,'"+ this.textBox2.Text + "' + '" + this.textBox3.Text + "');
                oleDbCmd.ExecuteNonQuery();
                Database5Conn.Close();
            }
        }
    }

    Thursday, April 3, 2014 11:50 AM