How to read excel data foreach cell and insert into database using stored procedure.
I have two tables like
create FormDetails (
form_id int NOT NULL IDENTITY(1, 1),
form_name varchar(100)
)
create FormDetailsByUser (
form_id int,
form_type varchar(100),
form_comment varchar(100)
)
I have connect to form_id to another table, also add two table at a same time. how to do that for examples normal we add like that without using excel data
objinfo.form_name = txtFormName;
int formid = AddProcedure_FormDetails(objinfo);
if(formid > 0)
{
objinfo1.form_id = formid;
objinfo1.form_type = txtFormType.Text;
AddProdcedure_FormDetailsByUser(objinfo1);
}
how to do like that excel data insert into database
I have use excel like that
form_name form_type form_comment
Form1 FormType1 FormComment1
Form2 FormType2 FormComment2
Form3 FormType3 FormComment3
Form4 FormType4 FormComment4
Form5 FormType5 FormComment5
Form6 FormType6 FormComment6
Form7 FormType7 FormComment7
Form8 FormType8 FormComment8
Form9 FormType9 FormComment9
Form10 FormType10 FormComment10
Form11 FormType11 FormComment11
Form12 FormType12 FormComment12
Form13 FormType13 FormComment13
Form14 FormType14 FormComment14
Form15 FormType15 FormComment15
first row is our table field name
fist column is one db table1 and second and third column is another db table2
We want to insert data into database table from excel First column is insert into table1 and return one identity id that id will connect to next table2 foregin key column2, column3 and return id from table1 that all insert into table2