Hi I have 2 datagridview, 1 richtextbox and 2 button
I want to do when I click the button1 create a table on datagridview1 and add the bulk datas from richtextbox to datagridview1 column
for example
No | Product Name
1 Apple
2 Banana
3 Pear
4 Orange....
.. ...
and when I click the button2 save as .xlsx file and list on datagridview2
What I can't make is adding bulk item to datagridview column from richtextbox all other I can do
what I'm asking how can I make this?
What I have tried:
using System.Data.OleDb;
OleDbConnection odc = new OleDbConnection
(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Yusuf\Desktop\x\bilgiler.xlsx;Extended Properties='Excel 12.0 Xml; HDR=YES;IMEX=1;'");
void veriler()
{
OleDbDataAdapter da = new OleDbDataAdapter("Select * From [bilgiler$]", odc);
DataTable dt1 = new DataTable();
da.Fill(dt1);
dataGridView2.DataSource = dt1;
}
private void button2_Click(object sender, EventArgs e)
{
odc.Open();
OleDbCommand cmd = new OleDbCommand("insert into [bilgiler$] (Products) values (@p1)",odc);
cmd.Parameters.AddWithValue("@p1",richTextBox1.Text);
cmd.ExecuteNonQuery();
odc.Close();
veriler();
}