Topic: Access Database Connectivity

First off I want to say, I am a complete newbie when it comes to ASP.NET. I am using Microsoft Visual Studio 2005 for this project.

Essentially, I am just trying to setup a basic form that I want the information, when submitted, to be inserted into an Access database. How do I go about setting up the database connection and running queries?

I am more familiar with PHP so, maybe you could compare that for me. Or give any good references, there is so much on ASP.NET that its somewhat confusing.

-- Dan

Re: Access Database Connectivity

First off, I would not use access, I would use SQL Express if you don't have the full version of SQL Server.  Access has some nuances and will not scale beyond about 20 concurrent web users.  SQL Express is free, is the SQL Server engine under the covers and allows you to build stored procedures, triggers, etc. where access does not. 

Secondly take a look at http://www.asp.net/Tutorials/quickstart.aspx.  In the left menu, click on the option for Performing Data Access.  VS.NET 2005 has some great rapid application tools for connecting to the database.  In short, you drop a grid to the form, in the smart tag you set up your connection, then your table, and bam you have your data.  Don't make it more difficult than it needs to be, it really is that easy.

Third, depending on the scale of your project, you may want to look into using the Enterprise Library components.  These are components built for enterprise applications, that make things like data access easy and consistent throughout your application.  You can find more info here: http://msdn.microsoft.com/practices/

Hope this helps!
Chuck

Re: Access Database Connectivity

Like I said, NEWBIE! ;-)

Thanks for the assistance.

The point of this project is to finish it in the least amount of time possible with as little effort. This is not going to be used for use on the internet or for heavy use. I was just going with Access since it was what I know. (I know MySQL, but Access I can send through email along with the web files.

I could still use more advice/assistance. Thanks.

-- Dan

Re: Access Database Connectivity

Are you using Web Dev Express or one of the full VS versions?

When you drag a data control to the design surface and set up the connection, it will ask you what type of database you want to connect to.  I would just start playing with it and if you have any questions, post those specifics.

Re: Access Database Connectivity

I need to know how to connect text fields to the Insert Command so I can insert those values into the database. I already switched to SQL, and I have a SQL Datasource on the page. How to I take control of that. I have a normal submit button on my form. I know the I can change the Click commands so I tried Me.sqlDatabase.Insert(), but it gives me errors all the time.

This is really hard to explain because this is such a robust application. I am using the full version of Microsoft Visual Studio 2005.

-- Dan

Re: Access Database Connectivity

Hi Dan,

I haven't worked with databinding in 2.0 yet, but I believe the control you want is the formview.  The table also should have a primary key or ID column, but I believe the formview control contains all of the logic for the updates and inserts.  You'll probably have to define both and ItemTemplate and an EditItemTemplate in the formview that will contain the labels and/or textboxes to display and receive the user's input.

Sorry I can't offer more specifics, but I'm pretty sure that's what you'll want.

Andrew