0

i am creating a website (asp.net and C#) and i need to read some data from access database (has file extension :.mdb or accdb) that chosen by user from his pc ,then use this data to update SQL server database with it.

so how to read data from access database at the client side and choose some of them (under some if statements) to update some records with it in SQL server database?

5
  • 2
    This is might be not possible at client side. you need to upload on server and access MS-access DB and manipulate data and download from there.. Commented Nov 27, 2012 at 8:45
  • so how to manage that and after uploaded and update data in sql i need to delete the uploaded one because the user will upload several times and i dont want to overload server with unused files Commented Nov 27, 2012 at 8:47
  • 1
    humm.. you can delete those DB file by creating scheduler program those are old at least one day(24 hour).. Commented Nov 27, 2012 at 8:54
  • ok good idea but could you please show me some codes for how to achieve the whole process ? Commented Nov 27, 2012 at 8:57
  • Have a look at this question about How to access an Access database using JavaScript? Commented Nov 27, 2012 at 9:08

2 Answers 2

1

you van call this method in your page_load event

public void RemoveTemporaryFiles() {
        string pathTemp = "d:\\uploads\\";
        if ((pathTemp.Length > 0) && (Directory.Exists(pathTemp))) {
            foreach (string file in Directory.GetFiles(pathTemp)) {
                try {
                    FileInfo fi = new FileInfo(file);
                    if (fi.CreationTime < DateTime.Now.AddHours(-24)) {
                        File.Delete(file);
                    }
                } catch (Exception) { }
            }
        }
    }
Sign up to request clarification or add additional context in comments.

Comments

1

It's not best practice to access the clients filesystem from out HTML/ASPX/ActiveX level for security reasons. Create a client Visual Studio Windows Forms solution (instead of the HTML/ASPX page) that can retrieve the records and submit them to an asp.net service (WCF) in your webapp seems to me the best option.

If you "really" need this functionality, you can always create an ActiveX component and embed that in your HTML/ASPX page. But still, I won't recommend this for a lot of reasons like browser compatibility, browser security settings, security in general.

Side note : You also could upload your dbase with the file up-loader component and then access your dbase on server side level and delete the dbase file afterwards again. Security wise not a thundering solution and you are uploading "all the data" instead of a few records in the first place like requested.

3 Comments

i am thinking to use upload method maybe this way will be more controled thanks a lot for clarify the disadvantages of others
i have a question now when i upload the access database how can i read data from there and access database will be at server that time. so i can use the usual way like this ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Mode=Share Deny None;Data Source="+strFileName; or because it is at server it will not work?
It will work :) You can use dynamic connection strings or even static if you know the exactly the dbase connection name. For Connection string setup surf to link You could use it like : Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=; surf to link Remember, IUSER need Read AND Write access to the directory, this is because of the temp lock dbase file it will create while reading the dbase.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.