Hi.
I am writing a program where I import data into a database with a System.Web.UI.WebControls.SqlDataSource object, using its Insert method.
Dim DataBaseConnectionString As New Web.UI.WebControls.SqlDataSource()
DataBaseConnectionString.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
DataBaseConnectionString.InsertCommandType = Web.UI.WebControls.SqlDataSourceCommandType.Text
DataBaseConnectionString.InsertCommand =
"BULK INSERT TBLMain FROM '/file.csv' WITH (FIRSTROW = 2, FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')"DataBaseConnectionString.InsertParameters.Add(
"csvdatapath", OFDCSV.FileName.ToString()) TryDataBaseConnectionString.Insert()
Catch ex As Exception
I have been able to get this working fine.
I need to export to (ideally) a .CSV or a .XLS. I have tried to use the:
Is it possible to use a simmilar method of interacting with the database through code to perform this
Thanks