vb.net - import excel to sql db table -


I am trying to write data from Axle Spread Sheet in the SQL database. I'm able to connect to Excel spreadsheets and read data, but I'm unable to get data to be inserted into the SQL DB table.

The current code is as follows

Any help most appreciated.

  Dim plmExcelCon System.Data.OleDb.OleDbConnection as the slow ldExcelDS system. As Data.DataSet dim cmdLoadExcel as System.Data.OleDb.OleDbDataAdapter Dim PrmPathExcelFile string PrmPathExcelFile = txtImportFileLocation.Text.ToString plmExcelCon = new Prnalikdeta. OleDb.OleDbConnection ( "Provider = Microsoft.ACE.OLEDB.12.0; Data Source =" + PrmPathExcelFile + ", Extended Properties = Excel 12.0,") cmdLoadExcel = new System.Data.OleDb.OleDbDataAdapter ( "[+ txtImportSheetName.Text + "$]", plmExcelCon) ldExcelDS = select new System.Data.DataSet * "cmdLoadExcel.Fill (ldExcelDS) dgvImportData.DataSource = ldExcelDS.Tables (0) plmExcelCon.Close () cmdINSERT.Parameters (" @ [SQL Column name] "). Value = [not sure to set datagrid value to view] cnLD. Open () cmdINSERT.ExecuteNonQuery () cnLD.Close ()  

I Excel It was the task of pulling some data, modifying it and putting it into a SQL database. Below I have something similar to be:

  dim MyConnection New System.Data.OleDb.OleDbConnection dim MyCommand System.Data.OleDb.OleDbDataAdapter MyConnection = new System.Data.OleDb. as as OleDbConnection ( "provider = Microsoft.Jet.OLEDB.4.0; data source =" + file location + "Extended properties = Excel 8.0;") to select data from the sample 'sheet of the workbook MyCommand = New System.Data.OleDb.OleDbDataAdapter ("Select * From [Samples $] ', MyConnection) Dim DS MyCommand.Fill as new dataset (DS) MyConnection.Close ()  

this is your There is already a lot more to do, and you have said that works to draw data from Excel. From there I will repeat it through datasets and add it to the database like this:

 Dot values ​​in the form of DataTable = ds.Tables (0) dt.Rows dormant values ​​as dt-dim as double-string ("columnName") for each line as DataRow in Dorm Value 2 = Row ( "ColumnName2") as a function of its parameters insertIntoDatabase (value 1, value 2) next   

Write connects to the database Hopefully that bridge is important to you (keeping in mind the DataTable data) Good luck!


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -