hi I am desperately looking for this solution,is it possible to insert new values to your table from the datagridview?the scenario is this: i have imported data from excel and display those data on a datagrid. now after displaying those data on the datagrid there is a save button wherein if the user clicks the button the displayed data on the datagrid will all be inserted to my existing table,can anyone help me with this?thanks
Code Importing Excel Data to Grid view
web.config
Code Importing Excel Data to Grid view
VB.NET:
Public Sub UpLoadExcel()
Try
Dim strExcelConn As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ExcelConnection1").ToString()
Dim dbConn As New OleDbConnection(strExcelConn)
'Dim db As OleDbDataReader
Dim strSQL As String
strSQL = "SELECT Item_no as LI,Part_no as PartNumber,qty as OrderQty,Mfgr_pt_no as MfgrPartNumber FROM [" & txtWCON.Text & "$] where Part_sourc ='CONSG'"
dbConn.Open()
Dim cmd As New OleDbCommand(strSQL, dbConn)
Dim dsExcel As New DataSet
Dim daExcel As New OleDbDataAdapter(cmd)
daExcel.Fill(dsExcel)
GVCparts.DataSource = dsExcel
GVCparts.DataBind()
Catch ex As Exception
Throw ex
End Try
End Sub
VB.NET:
<connectionStrings>
<add name="ExcelConnection" connectionString ="Provider=Microsoft.Jet.Oledb.4.0;Data Source=|DataDirectory|\WO.xls;Extended Properties=Excel 8.0"/>
<add name="ExcelConnection1" connectionString ="Provider=Microsoft.Jet.Oledb.4.0;Data Source=|DataDirectory|\6496.xls;Extended Properties=Excel 8.0"/>
</connectionStrings>