Question : ACCESS IMPORT MS EXCEL FILE

Hi All,

I have an Excel file named TEMPLATE_1.xls.

The first sheet (Named EX_RATES) contains 3 fields: STATE (Number), CURRENCY (Text), EX_RATE (Number)

In my access database, I want to automatically import the data from the template into a table named MT_EXCHANGE_RATES that already resides in my database. In addition, I also require some form of validation so that the user cannot just import any old thing.

Any possible solutions?

I have enclosed sample data to help.

Thanks in advance.

CF


Attachments:
 
TEST_DB
 
 
TEMPLATE_1
 

Answer : ACCESS IMPORT MS EXCEL FILE

Hi
try this code in Add and Save button click events

private void btnAdd_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Add();          
            dataGridView1.Rows[inindex].Cells[0].Value = txtdescription.Text;
            dataGridView1.Rows[inindex].Cells[1].Value = txtformulaname.Text;
            dataGridView1.Rows[inindex].Cells[2].Value = txtFormula.Text;
            inindex++;          
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow Row in dataGridView1.Rows)
            {
               /*take each cell value   like this
 value1=Row.Cells[0].Value;
value2=Row.Cells[1].Value,
value3=Row.Cells[2].Value; and Save to Database*/
            }
        }
Random Solutions  
 
programming4us programming4us