Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 .xls file as linked server

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2005-09-30 : 16:32:02
I've setup, through DTS, my linked server as an .xls file.

What I want to do is have a .aspx page which allows the user to upload a .xls file to the following database server directory:
C:\TestSaving
I've got the code to read the file once it's in the directory and select all the rows from the .xls file and insert them into a table, but I can't get the file to save into the database server directory above. I had to hand create it to get the whole update process to work.

Here's my code:

***************

Dim getmyFile As HttpPostedFile = myfile.PostedFile
Label2.Text = "Line 76"
If IsNothing(getmyFile) Then
Label2.Text = "Please select a file to upload"
Else
If getmyFile.ContentLength = 0 Then
Label2.Text = "Cannot upload zero length File"
Else
Dim ServerFileName As String = Path.GetFileName(myfile.PostedFile.FileName)
Server.MapPath("//db2")
getmyFile.SaveAs("C:\TestSaving\" & ServerFileName)
Label2.Text = "Successful upload to C:\TestSaving\" & ServerFileName

****************

Any suggestions are welcome!

Thanks!
   

- Advertisement -