Hi all, i'm totally newbie need help the code to transfer dataset/datatable into sql table. Before insert the data into database, first i have to edit some values. Please give me a clue. I'm trying to import excel to sql server 2000.
Last time i run the application, it occurs an error which is : Column 'KEY' does not belong to table Table.
Please give me a clue...Thanks in advance
VB.NET:
Dim dsSQL As New DataSet
ProgressBar1.Maximum = dsSource.Tables(0).Rows.Count
Dim importDA As New SqlDataAdapter("SELECT * FROM " & tblname, oconnection)
Dim importDB As New SqlCommandBuilder(importDA)
'importDA.MissingSchemaAction = MissingSchemaAction.AddWithKey
importDA.Fill(dsSQL)
'importDA.InsertCommand = importDB.GetInsertCommand
''MessageBox.Show(importDA.InsertCommand.CommandText.ToString)
''MessageBox.Show(importDB.GetInsertCommand.CommandText.ToString)
'Dim r As DataRow
'For Each r In dsSource.Tables(0).Rows
' r.SetAdded()
' ProgressBar1.PerformStep()
'Next
Dim r As DataRow
Dim col As DataColumn
For Each r In dsSource.Tables(0).Rows
Dim drnew As DataRow = dsSQL.Tables(0).NewRow
For Each col In dsSQL.Tables(0).Columns
drnew(col.ColumnName) = r(col.ColumnName)
Next
dsSQL.Tables(0).Rows.Add(drnew)
ProgressBar1.PerformStep()
Next
Label5.Text = "Proses import data...."
importDA.Update(dsSource)
dtSource = dsSource.Tables(0)
'DataGridView2.DataSource = dtSource
ProgressBar1.PerformStep()
oconnection.Close()
Last time i run the application, it occurs an error which is : Column 'KEY' does not belong to table Table.
Please give me a clue...Thanks in advance