Hi,
I have a csv file upload to datatable using TextFieldParser.
Since i don't want any duplicate records and wants to update if same ID has been imported to database, then I have followed this tutorial to use Stored Procedure and no longer use SqlBuckCopy.
In SqlBuckCopy, I can column mapping from datatable with specific column name in sql database like this
sqlBulkCopy.ColumnMappings.Add("CGPA", "e_cgpa")
sqlBulkCopy.ColumnMappings.Add("Code", "e_code")
However, how can i do the same with stored procedure that just directly pass the datatable?
Using cmd As New SqlCommand("Update_Students")
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = con
cmd.Parameters.AddWithValue("@tblStudents", dt)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
I read that the user defined table type column's name must be same with column on the datatable, but my datatable column name most of it consists 2-3 words.
How can i cater this issue?