I have a Class that is creating a large dataset (over 32,000 records) on the fly. I want to take the dataset and import it directly into SQL Server 2005 but I have not been able to find anything in ADO that allows me to do that all in one chunk.
Doing a search I found some people in a similar situation that have exported the dataset to an XML file and then imported into SQL Server, which seems like a long way to go just to get something done that I would think would be part of ADO.Net.
However, for lack of a better option, I went a head and created the XML file but now I am having problems getting it to import into SQL Server so before I lose another day of productivity I am goin to ask a question.
Is there a way to insert a dataset directly into SQL Server without going to a file first (even if I have to do it one row at a time)?
VB Code:
' cnn.Open() Try Dim cmd As SqlCommand = New SqlCommand("TimeCards", cnn) cmd.CommandType = CommandType.StoredProcedure cmd.CommandTimeout = 0 cmd.Parameters.AddWithValue("@StateID", "45") cmd.Parameters.AddWithValue("@StoreID", "ABCDEF") cmd.Parameters.AddWithValue("@From", dtStartDate) cmd.Parameters.AddWithValue("@To", dtEndDate) cmd.ExecuteNonQuery() da.SelectCommand = cmd da.Fill(dsHours, "EmpHours") CheckForFile(strFilePath) Catch ex As Exception bolSucceed = False Finally cnn.Close() cnn.Dispose() da.Dispose() End Try




Reply With Quote