I am reading a CSV file into a dataset and trying to insert this dataset into an existing SQL table. The problem I am having lies in the fact that the dataset I have contains 2 columns, and the SQL table has 20+ columns.
I can't get any data to be inserted into the SQL table from the dataset, I really don't know what I am doing wrong here. Thanks for any help or suggestions.
Public Function DatasetToSQL() As DataSet
Dim ds As DataSet
Dim dr As DataRow
Dim da As SqlDataAdapter
Dim punchtime As String
Dim eventtype As String
Dim sqlconn As New SqlConnection(GetConnectionString())
Try
ds = ConnectCSV()
sqlconn.Open()
For Each dr In ds.Tables(0).Rows
punchtime = ds.Tables(0).Rows.Item(0).ToString eventtype = ds.Tables(0).Rows.Item(1).ToString
da = New SqlDataAdapter("INSERT INTO ClockData (DateTime, EventTypeID) VALUES (" + punchtime + "," + eventtype + ")", sqlconn)
da.Update(ds, "CSVData")
Next
Catch ex As Exception
End Try
End Function