0

I need to connect a simple AngularJS application to a local MS Access database stored in the same folder as the app. Due to firewall restrictions, I cannot use npm and modules such as express. I am hoping to directly connect to the db using ADO and ASP.NET.

I have looked into ADO but due to my lack of background ASP.NET & db knowledge, I have gotten stuck. Take for example the following code:

function AddRecord() {
    var adoConn = new ActiveXObject("ADODB.Connection");
    var adoRS = new ActiveXObject("ADODB.Recordset");

    adoConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='/\dbName.mdb'");
    adoRS.Open("Select * From tblName", adoConn, 1, 3);

    adoRS.AddNew;
    adoRS.Fields("FieldName").value = "Quentin";
    adoRS.Update;

    adoRS.Close();
    adoConn.Close();
}  

This was taken from another StackOverflow question. I have no idea where to put this code, but here is a Plunkr with my existing code. As you can see, its a very simple app. Could anyone give me some direction as to what to do?

Community
  • 1
  • 1
Kangze Huang
  • 351
  • 7
  • 22
  • Connect for what purpose? Full CRUD operations? Does it have to be an access database? – jbrown Jan 05 '16 at 21:15
  • Yes for full CRUD operations. It does not have to be an access db but anything else could run into troubles with installations on production servers. Also most other db have been in Access so consistency would be ideal. – Kangze Huang Jan 05 '16 at 21:33
  • The standard for accessing a database in an AngularJs is to make an ajax call via the native $http service to some form of api. In your case, you seem inclined use Microsoft technology so that api will be using their WebApi. Search the web for tutorials (there are many) on building a single page application (SPA) using AngularJs and WebApi. Additionally, I would consider using SQL Express rather than Access for a db. They both have limitations concerning connections but it would be easier to scale up to SQL Server down the road, if necessary. – jbrown Jan 05 '16 at 21:44
  • Do you think this is possible using ONLY Angularjs $http and the WebAPI? Or would I also need to install Express or some other web server? – Kangze Huang Jan 05 '16 at 22:00
  • You could run under IIS. Or you can build your WebApi to be self hosted. – jbrown Jan 05 '16 at 22:04
  • I believe IIS is already set up, but I don't know how to connect it. However, I see that when I place my project into the master directory of hosted apps, I can see it from my company's intranet simply by appending /myapp to the master url. Does this mean Angular+WebAPI can get the job done? – Kangze Huang Jan 05 '16 at 22:07
  • Yes, that should get the job done. – jbrown Jan 05 '16 at 22:08
  • Ok well thats a lead i'll try. Thanks for all the advice! :) – Kangze Huang Jan 05 '16 at 22:11

0 Answers0