importing excel sheet into a database table [modified]
-
hi, In my application i need to import the excel sheet data into a database table "Emp_Profile_Tbl" which is created in the database. Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Team wise EMP Profile (2).xls") + ";Extended Properties=Excel 8.0;" Dim objconn As New OleDbConnection(connstr) Dim ds As New DataSet Dim objadapter As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", objconn) objadapter.TableMappings.Add("Table", "Emp_Profile_Tbl") Try 'in excel: insert->name->seleziono il range:nomi objconn.Open() objadapter.Fill(ds) dg_empprofile.DataSource = ds.Tables(0).DefaultView dg_empprofile.DataBind() Finally objconn.Close() End Try i'm getting the values into datgrid but the values are not saving in "Emp_Profile_Tbl" database table. pls help me to sort this out. Thank u,
modified on Thursday, December 13, 2007 2:37:51 AM
-
hi, In my application i need to import the excel sheet data into a database table "Emp_Profile_Tbl" which is created in the database. Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Team wise EMP Profile (2).xls") + ";Extended Properties=Excel 8.0;" Dim objconn As New OleDbConnection(connstr) Dim ds As New DataSet Dim objadapter As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", objconn) objadapter.TableMappings.Add("Table", "Emp_Profile_Tbl") Try 'in excel: insert->name->seleziono il range:nomi objconn.Open() objadapter.Fill(ds) dg_empprofile.DataSource = ds.Tables(0).DefaultView dg_empprofile.DataBind() Finally objconn.Close() End Try i'm getting the values into datgrid but the values are not saving in "Emp_Profile_Tbl" database table. pls help me to sort this out. Thank u,
modified on Thursday, December 13, 2007 2:37:51 AM
sivaram praveen wrote:
i'm getting the values into datgrid but the values are not saving in "Emp_Profile_Tbl" database table.
You haven't written any code to save the data back to your database, so it's hardly surprising that nothing is happening. You need to specify insert/update/delete commands for your data adapter so that changes to the dataset can be propagated back to the database. Read this article[^] for more information.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush