How can I insert splitted texts to my ms access database?
I can't seem to find the logic in it. :(
Please help me.

Here are my codes:

This is where i split the texts that are inputted in textBox1, textBox2, and textBox3

string items = textBox2.Text;
    string[] splittedText1 = items.Split(' ');
    string quantity = textBox1.Text;
    string[] splittedText2 = quantity.Split(' ');
    string price = textBox3.Text;
    string[] splittedText3 = price.Split(' ');

and this is the code where I will insert those texts to my database:

OleDbCommand CmdSql = new OleDbCommand("Insert into [sales] ([productname], productquantity, productprice) VALUES (splittedText1, splittedText2, splittedText3);

is this even correct? Please help!

Try this:

OleDbConnection con;

        private void button1_Click(object sender, EventArgs e)
        {
            string items = textBox2.Text;
                string[] splittedText1 = items.Split(' ');
            string quantity = textBox1.Text;
                string[] splittedText2 = quantity.Split(' ');
            string price = textBox3.Text;
                string[] splittedText3 = price.Split(' ');

            con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=path_to_your_database_file;
                                Persist Security Info=False;");  // have a look here if you run into trouble
                                                                // http://www.connectionstrings.com/access/
            con.Open();
            for (int i = 0; i < splittedText1.Length; i++) // the ID's will be updated automatically,
            {                                              // supposing that all arrays correspond to each other(the sizes are the same)


                OleDbCommand cmd = new OleDbCommand(@"INSERT INTO Product (productname,productquantity,productprice)
                                                  VALUES (@items,@quantity,@price)", con);
                cmd.Parameters.Add(new OleDbParameter("items", splittedText1[i]));
                cmd.Parameters.Add(new OleDbParameter("quantity", splittedText2[i]));
                cmd.Parameters.Add(new OleDbParameter("price", splittedText3[i]));

                cmd.ExecuteNonQuery();

            }
            con.Close();
            con.Dispose();

        }

have a look at the comments,

OleDbCommand CmdSql = new OleDbCommand("Insert into [sales] ([productname], productquantity, productprice) VALUES (splittedText1, splittedText2, splittedText3);

It is enough to specify the table name without the brackets the squared bracktes [] and the values without the square brackets as well [].

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.