ASP.Net web site on IIS connecting to Access DB with Links to SharePoint lists on another machine - asp.net

My Problem is the following,
I have an ASP.Net web site hosted on IIS. This web site connects to an Access 2007 DB file on the same server. The DB file contains links to sharepoint lists on another server on the same domain. If I run the web site on the visual studio built-in server, I can Open connection to the DB file and retrieve data just fine. But whenever I try to run the web site over the IIS, the web site can't open a connection with the DB file.
What do you think the problem is?
Thanks.

It will be a permissions problem. When you run with Visual Studio's web server it is running as you, IIS on the other hand runs (by default) as Network Service. This is limited in what it can do.
To access an access database (no pun intended) the account that IIS runs under will need the ability to read, write, execute, change and delete for the directory the database is in. By default this should be granted to the APP_DATA directory, if your access database is elsewhere you will need to grant these permissions.
Connecting via Access to a remote machine is a whole other problem, it's unlikely this will work because the Network Service account is a local account and will not exist on the sharepoint server, and you cannot grant access because it does not exist.
If you were in a domain you could run IIS under a suitable locked down domain account and it might work, but frankly it's all a bit messy!

Have a look at this article:
How to connect to a remote Access database from Active Server Pages
http://support.microsoft.com/kb/253580
Yes, I know your database is on the same machine, but there are differences in permissions and authentication for files and folders when you run IIS. The chances are good that whatever is hanging you up is covered in this article.
Whether mixing Access databases and IIS is a Good Thing or not is a separate discussion...

Access 2007 makes connecting to SharePoint a breeze. After you link to a list, then ADO, and even DAO + VBA code and your sql queries work on those lists!
I seen a good number of people thus start using the JET (actually it called ACE in access 2007) as a data connector to SharePoint for this very reason. Since your are building a web based system then we not using ms-access here, but ONLY using the 2007 version of the JET data engine that ships with access 2007.
Someone does need to come out with a OLEDB provider for SharePoint lists that allows ones web site or .net code to view those lists as standard sql tables like ms-access can. Using JET as the data connector system is likely not such a good idea. I do realize that you not storing nor placing data in the access JET table, but are using the wonderful ability of the new access JET engine to view and use SharePoint lists as regular sql tables. This approach does allow your ASP.net code to execute sql updates on that data or do whatever as if this was a regular sql table. It does make this oh so easy.
The security permissions on the SharePoint site are thus going to view this connection as not as a end user, but always see the USER as the actual web site connecting (or at least the user you were in ms-access when you linked the table to SharePoint). I don’t believe the SharePoint user authentication process can work reliable when you do this. What will happen is you change a few things on the SharePoint site, and next thing you know the JET connection will be trying to prompt you for new logon credentials. You can’t provide nor control those logon credentials at that point in time.
So, as others pointed out, this is going to be problematic and not reliable.

Using Access as a fudge to access SharePoint from an ASP.net site is going to give you lots of pain in the long run.
A much better way would be to use SharePoint's web services to access that data - removing Access from the equation altogether.
http://www.scribd.com/doc/8634090/Accessing-SharePoint-Data-Using-C-Without-Running-Code-On-the-SharePoint-Server-Part-1
MSDN - Using ASP.NET web services
Creating and Consuming a Web Service

Related

Connections issues with MS Access to ASP.NET web application

I have hit a wall and can't figure out the heads from the tails. I am working with a team and we have developed an asp.net web application. There is a feature on the application that delivers directions from a database. The database is an MS Access database. I have published the application to an IIS7 Windows server. I also uploaded via FTP the Access database. We have tried all manner of connection string variants. We did not import the database in any way into Visual Studio but prefer to connect to where ever we decide to place it.
Now, I am wondering if using Access was a bad idea. Its a given that it was a rookie mistake since we are students working on our capstone project. Is there any other installs for the Access database that need to be installed on the server other than the driver for Access? Should my connection string be structured any other way that what it is presently? I will post the string below. Please note, I did not write this particular section of coding so if an error should be thrown it may be handled somewhere as to prevent the application from crashing on the user. Side note: Yes it does work fine on my local computer although the connection must be altered.
sConnection = #"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\inetpub\wwwroot\kioskApplication\www\Waypoints.accdb";
Thanks in advance for all the support and help with this issue.
Usually a WEB Application stores a file based database like MS-Access in its APP_DATA folder under the root of the site where every permission is granted to the IIS Service.
Then in your connection string you refer to this location using
Connection = #"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=|DataDirectory|\Waypoints.accdb";
See Where is DataDirectory
On the server side there is no need to install anything apart from the Microsoft Database Access Engine appropriate for the bitness of your web application. (32bit or 64bit)

Which database to use for C# ASP.NET website?

I am developing an online internal web portal (like users write tests, provide document links to study, completing a study roadmap, admin user to view ststistics, etc). It caters some 150 users. I have planned to use ASP .NET with c# in Visual Studio 2008 on windows xp. I am implementing using Forms and NOT MVC since I feel at home with forms.
I do not want to use windows authentication since each user will have many attributes related to him and so it will be easy using a database. Security is not an issue since it is being used internally only.
I have only a fair knowledge about ASP and C# and VS 2008.
Now my questions:
Can I use MS SQL server database that is built in in VS 2008?( I cannot ask for external databases)
Can I export the website totally along with the databases to IIS server running in some other computer? How?
Do I need to export databases separately or provide a database creation script like PHP?
(I have more questions. Will update once I start off).
(This is my first .net web app. so can i know where i can find login scripts, pagination, examples, and pretty much all the stuff)
edit: which to use? New website or New Webapplication?
You can pretty much use any database, but it seems from your requirements that you want to look closer towards something like SQLExpress, SQL Server Compact Edition or SQLLite.
Can I export the website totally along
with the databases to IIS server
running in some other computer? How?
Your database will be shipped along with your application if you use one of the database options that I have specified above.
Do I need to export databases
separately or provide a database
creation script like PHP?
See my comment above, the database will exist when you deploy your website to IIS. It's a physical file that will be in your APP_DATA folder.
You can use:
MySQL. The reason: It has no space or memory limit!
SQL Server or SQL CE. These are both alike. They just differ in slite functions, and also the storage!
The SQL CE allows you to have 4GB. But the SQL Server lets you have 10GB.
So it depends on your work!
Also, I wanted to point out one error in a post, that the SQL CE is present in App_Data, Correct! But the SQL Server is placed somewhere like:
C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\here_will_it_be
And yes, you can migrate it to wherever you want to place it. I mean if you want to upload it to a hosting server, you can upload it using Web Deploy! Or what ever service. When downloading you will have to repeat same process!
I hope you are doing good with your first web app! :)

problems with user instance SQL Server 2005 Express mdf file

I have a web app that I am working with on a separate server. I didn't originally create it, but I have to maintain it. I had to to do some manual editing of one of the database tables, which I did through Visual Studio 2008 installed on the same machine. Now I get SQL exceptions regarding Network Service not having the right privileges.
How do I avoid this from happening? I haven't modified any settings regarding the security or access information. It was working before I made the modification, and now it isn't.
Thanks!
Did you by chance change the connection information stored for the DB? Perhaps remove a explicit user (SQL Authentication) and replace it with a Trusted_Connection?
Also did you change the webserver to no longer use authentication?
The error sounds like it is coming from the fact that the Network Service account (the one generally responsible for running ASP.NET pages) cannot access the DB. This happens mostly when authentication is disabled, and there is no explicit SQL Authentication.

SQL Express User Instance with multiple ASP.NET Sites

How can I get two separate ASP.NET sites, in this case a Web Site using Entity Framework and Web Service, to use the same local database mdf & ldf?
I looked around and I think that this kind of local DB is called a User Instance - at least they way I'm currently using it. I wasn't sure if it would work or not until I found the below info from the MSDN Library and now I'm really not sure if it will work.
User instance scenarios include:
...
Dedicated ASP.NET hosting using Windows Authentication. A single SQL Server Express instance can be hosted on an intranet. The application connects using the ASPNET Windows account, not by using impersonation. User instances should not be used for third-party or shared hosting scenarios where all applications would share the same user instance and would no longer remain isolated from each other.
Will this work right away without any extra configuration? When I try to add a DB to every successive application, I get a file in use error if anything else is using the DB which leads me to believe that I can't do it this way. However, if I stop the DB from being used, then add it, and then start it up, it seems to work fine. Does anyone have any reassurance for me that it won't be corrupted or experience any errors by using it this way?
Preferably, the mdf & ldf would be stored in the Web Site's App_Data directory (|DataDirectory|). If I do it this way, I don't think I can reliably use relative addressing for the Service unless I put it in a sub directory for the Site, is this correct?
edit: I'm using SQL Server Express because this is an assignment for school, so I pretty much have to use it. If there is a way without User Instance I'll try to do without it.
You can't use User Instance for this. This allows just one client at a time to connect to your database. When your two applications use the same credentials, you get the error you describe. When your two applications use different credentials, you essentially get two separate instances (also not what you want).
Besides, user instances are only supported on SQL Server Express. I don't know what your production environment looks like, but it probably does not run on SQL Server Express?
You should use AttachDBFilename in the connection string of your web application to point to the local database: AttachDBFilename=|DataDirectory|\MyDB.mdf.
In your web service you also use AttachDBFilename but it depends on the deployment location of the web service where to point it to.

Best practices for maintaining shared hosting websites with ASP.NET and SQL Server?

I've been doing PHP/MySQL websites with shared hosting providers for the last couple years. The day-to-day process is basically:
develop in Eclipse, one website per folder
upload via FileZilla, one website per folder
use PHPMyAdmin to create and manage your local and online databases and transfer data from one to another
to backup the online database I do dump of the database tables into script and copy them locally
I now want to build websites with ASP.NET with SQL Server 2008 on shared hosting providers, and am trying to get into this new paradigm, hopefully some of you can give me some pointers based on your experience and tell me what I am not doing optimally:
I've installed both the Visual Web Developer 2008 Express as well as the full version of Visual Studio 2008, both seem to be full-featured tools for developing ASP.NET sites. In terms of websites at shared hosting providers, what can you do with the full version that you can't do with the express version?
I use FileZilla to upload my sites, which seems to work fine. Do you use an external FTP program to upload your sites or do you use the "Publish" or "FTP Website" in the above IDEs?
I installed SQL Server 2008 Management Studio and can now issue SQL commands to my online SQL Server database (although I strangely can't see my database in the list on the left, I can still access it, I assume this is some rights issue with my provider, www.domainbox.de, but this provider told me to use their online manager instead, which is called "ASP.NET Enterprise Manager" which is extremely simple but at least has a "Query Box" which allows me to send queries to my database.) Is this "ASP.NET Enterprise Manager" standard with ASP.NET hosters or is there something else that is better, e.g. where you could edit your data in the grid, etc.? And I assume that with most providers you are able to manage your online SQL Server database with SQL Server Management Studio, is that correct? (I remember back in 2001 managing online SQL Server 2000 database at a shared hosting provider with Enterprise Manager and it would take literally 10 minutes for me to see my database on the left because it listed out the other 800 customer databases as well -- hopefully this has been solved by now).
How do you backup your data in your online database to local storage? (currently I would have to write code that output my data to some other format, e.g. XML or SQL Script)
And after you make a number of structural and data changes to your local database, how do you transfer those changes and the new data to your online database? (I had to install SSMS Tools [http://www.ssmstoolspack.com] to be able to dump my data into a script so that I could get it back into my online database).
So, although I've gotten most things to work, I feel like there must be better ways to go about this, better providers, better tools, etc. Would like to hear some "best practices" advice from anyone who works with ASP.NET, SQL Server and shared hosting.
For the most part, what you're doing now will work with an asp.net website.
For your development environment, I don't think you will be limited by using Visual Web Developer 2008 express for what you want to do. Here is a microsoft page that compares every version of visual studio 2008, including Visual Web Developer 2008 Express: Visual Studio 2008 Product Comparison
For deploying your website over the net, I would generall stick to deploying manually. You can use some of the automated stuff in visual studio, but your deployment will tend to be a little slower. After compiling your application, it will then delete every file in your destination website, and upload everying from scratch (uncompressed I think). Your whole site will be down while this happens. When you deploy manually you can upload just the changed files, or everything in a compressed format.
Regarding the SQL server, many shared hosting services will let you connect with some sort of local SQL management tool. However, connecting this way generally uses a lot of bandwidth so they throttle the allowed bandwidth for this way down. This is probably the performance issues you previously saw. If you can get by with it, I would use their hosted SQL tools for most of your work, but then use the management studio for anything it can't handle.
For backing up your SQL server, if your host doesn't have a way for you to perform an automatic backup then you will have to do something yourself. I would first check to see if they will allow you to at least run a SQL backup command. This will generate a .bak file of your database, but on the local database server. Most places will work with you on this, since many customers need this.
For applying changes to your database, your best bet is to script all of the changes into one sql script and run it using the remote SQL management tool. These aren't hard to write, and there are a few tools out there that will help you with it. I personally like to use Visio. It lets me compare two databases (local and remote) then generate a script to apply to the remote one with all the changes.
Good luck
As far as capabilities of VS Express vs Standard - Standard is still the better tool. It gives you a richer debugging experience, broader support for solutions/projects dependencies among other things.
These things still matter even when doing shared hosting b/c you absolutely need to debug your app (client and server side). You can do this adequately with Express with some caveats (cant attach to an arbitrary process, client side javascript debugging is a pain), Standard makes this MUCH easier.
For publishing/deploying - I would recommend 'Web Depoyment Projects' - an MSBuild extension that you can download from MS. This gives you a lot of customizability of how you want to build and deploy your website - which can include sending it to an FTP site. If you have ever used MSBuild and like it - Web Deployment Projects are the easiest hook to extend your build process with an ASP.NET website.

Resources