I have the following code to import a csv file to my local sql database :
Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings("SQLConnStr").ConnectionString)
cn.Open()
Using copy As New SqlBulkCopy(cn)
copy.ColumnMappings.Add(0, 0)
copy.ColumnMappings.Add(1, 1)
copy.ColumnMappings.Add(2, 2)
copy.ColumnMappings.Add(3, 3)
copy.ColumnMappings.Add(4, 4)
copy.ColumnMappings.Add(5, 5)
copy.ColumnMappings.Add(6, 6)
copy.ColumnMappings.Add(7, 7)
copy.ColumnMappings.Add(8, 8)
copy.DestinationTableName = "Table"
copy.WriteToServer(dt)
End Using
End Using
At the line : copy.WriteToServer(dt), I get the following error : Cannot access destination table 'Table'. I know dt was created and filled, by using a break point and clicking on the magnifying glass when I hover over dt in the code.
I am using a local sql database with the following connection string :
Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\SkedDataBasis.mdf;Integrated Security=True
If have tried to make Integrated security = False, but to no avail.
Any help would be greatly appreciated. Regards