c00lbeans Posted January 23, 2004 Posted January 23, 2004 Hi what i want to do is enable the user to select an excel file from the disk and then make a connection to the file. I am using the HTML control file field and using it as a server control. I get the file name , add it to my connection string and try to open the connection. string FileName = InputFile.Value; ConnectString = @"provider=Microsoft.Jet.OLEDB.4.0;data source=+FileName;Extended Properties=Excel 8.0;"; OleDbConnection Connection = new OleDbConnection(); Connection.ConnectionString = ConnectString; Connection.Open(); I get the following error, "The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data." If i hard code the filename in the connection string i dont get the error. Any idea about this?, i am not opening the file using FileName.Value, just getting its name. thanks Sam Quote
bungpeng Posted January 24, 2004 Posted January 24, 2004 I just curious about your case: The excel file is in client machine, you suppose to upload the excel file to server before you can open it right? Quote
Moderators Robby Posted January 25, 2004 Moderators Posted January 25, 2004 try this... ConnectString = @"provider=Microsoft.Jet.OLEDB.4.0;data source=" + FileName + ";Extended Properties=Excel 8.0;"; Quote Visit...Bassic Software
c00lbeans Posted January 26, 2004 Author Posted January 26, 2004 Thanks Thanks to both of you, Robby the quotes you suggested, worked. bungpeng i am thinking about your question and i feel i have it planned the wrong way. I am fairly new to web based stuff. Yes i think now i will write code where he will upload the file to the sever first and then will call the code to open it. Do you know which controls i should use, or do u have a asnippet ? thanks Sam Quote
c00lbeans Posted January 26, 2004 Author Posted January 26, 2004 Hi guys thanks for the earlier replies, now i have modified my code so that i first uplaod the file to the server , and then try to open it. I am uploading and saving it using InputFile.PostedFile.SaveAs(FilePath); After this i again construct my connection string using Robbys suggestion of putting quotes and when i run it i am back to square one where it gives me the error. "The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data." why does this not work after uploading. Also I have used saveAs so i expected to find the file uploaded at the path i specified , but i dont see the file there? kind of confused? any suggestions thanks Sam Quote
bungpeng Posted January 26, 2004 Posted January 26, 2004 I think it is permission problem, did you check your folder permission setting? Normally I will set it "Full Control" to user "everyone". Quote
c00lbeans Posted January 26, 2004 Author Posted January 26, 2004 Hi bungpeng, yes i had it set to "Full Control" for everone. So it coudnt be that. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.