2 Replies - 2849 Views - Last Post: 28 April 2012 - 10:26 AM Rate Topic: -----

#1 rooster-run90   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-April 12

Visual Web Developer + ASP.NET + Database interaction

Posted 28 April 2012 - 06:33 AM

Hi, I'm currently struggling to complete an SQL Database assignment due in next week. 1 of a group of 4, I've basically been tasked with connecting the database to some front end web forms as no one has any real experience with web development. I'm only comfortable with PHP and have never used ASP.NET or SQL Server, so my question is simple really but I'd appreciate an extended answer to really help with my troubles.

I'm using Visual web developer because I do not know how to code in ASP or vb.net, and have been hoping the gui will allow me to simply drag and drop most things, however I don't know how to do things like the following:

When selecting a listbox index containing database records from a table, I want to display the corresponding database information of that particular record in an adjacent form of some kind.

Also upon selecting a index from the list box and clicking a button, to update that specific record in the database?

So far all I've managed to do is create a data source in the listbox to display the items, but cannot think of how to work with them as explained above. Please remember I am COMPLETELY new to ASP and Microsoft products, I'm only really comfortable with PHP and MySQL.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Visual Web Developer + ASP.NET + Database interaction

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14168
  • View blog
  • Posts: 56,762
  • Joined: 12-June 08

Re: Visual Web Developer + ASP.NET + Database interaction

Posted 28 April 2012 - 10:14 AM

OleDb Basics in VB.Net Rate Topic

A Really Simple Database Create a Database using Access & VB.net Express 2008

It sounds like you need to bust some learning quickly.

Upfront what you need to remember is aspx is two separate bits in one.. you have the html-ish front end gui and the vb.net/c# back end. You can think of the backend as the php - code that tends interacts on the server side... versus the HTML front end for displaying the controls. The front end has events that can be triggered (by the user) to interact with this code behind to do fairly complex tasks.. similar to say something like javascript. You can also use quite a bit of ajax controls in that gui bit if you are familiar with them.

Quote

have been hoping the gui will allow me to simply drag and drop most things,

It works well with the GUI components but not your database interactions since those are usually very specific.



Quote

When selecting a listbox index containing database records from a table, I want to display the corresponding database information of that particular record in an adjacent form of some kind.


This is a good example of straight forward control->event->codebehind->update gui scenario.

Plunk a list box down on your form from the toolbox.
in the properties panel there should be a little lightening bolt..that shows the possible events for that control. Find the one called 'selected index changed' and double click it. That should auto wire up the event for you and take you to the code behind.

From here, in the 'selected index changed' event of that list box... you'll need to create a few database objects (see the tutorials above for a similar outline).. a sql connection to your db.. a sql string to query the database... and then execute it.

The select statement should take the 'selected value' from the listbox as input for the where statement.

When you execute this you'll get a dataset back.. like in php... and you need to take that dataset and fill what ever form you were talking about.

Now.. that's a good way to read data using a listbox, but how do you fill a list box? I would guess you wanted to fill it on the form's load event. So flip back to the gui.. click in a blank area of the form.. hit up the lightening bolt for the events.. find the load.. and double click that. Again it should auto wire that for you.

In there you'll do something similar to what I outlined above for the database objects but with the dataset coming back you need to assign that to the listbox as a datasource and specify a datamember..

You can read up on all that at the msdn helpfiles on the listbox for asp.
http://msdn.microsof...ls.listbox.aspx

which appears you are already there so you can totally work back that knowledge for the index being changed and getting dynamic data back!
Was This Post Helpful? 1
  • +
  • -

#3 rooster-run90   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-April 12

Re: Visual Web Developer + ASP.NET + Database interaction

Posted 28 April 2012 - 10:26 AM

Thanks for such an awesome and detailed reply!
I've +1'd your post and will give it all a try.
I've been fiddling for a couple of hours and came across event handlers and such so I'll give it a shot.

Touch wood I won't get stuck xD Cheers.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1