|Reading the table into a
DataTable and adding that to a
DataSetis what I would recommend, but iterating over the list of values in the text file and using a simple
SqlParameters (so you declare the command one and parameterize it to simply change the values and call
ExecuteNonQuery) would also be easy and more efficient.
If you want to use the
SqlDataAdapter, you must at least have the
SelectCommand assigned to with a
SqlCommand for your SELECT statement. In order to insert, update, or delete rows, however, you must have the
DeleteCommand assigned on the
SqlDataAdapter. You can use the
SqlCommandBuilder with the
SelectCommand if the command is simple enough (i.e., JOINs and other advanced statements are not supported). Also, the
SelectCommand must be parameterized (see the
SqlDataAdapter class documentation in the .NET Framework SDK (installed by default with VS.NET, and available online from http://msdn.microsoft.com/netframework[^]) for more information and an example of how to use some of these classes.
Microsoft MVP, Visual C#