Saturday, March 24, 2012

Newbie Help! - Inserting Data into SQL

Hi All,

I need some help with ASP.NET 2.0. I come from a strong classic-ASP / VBScript / SQL development background and I'm now learning .net 2.0 to get back into the swing of things. So far I have hit a few snags, and this is the latest that I have not been able to get around.

What I have is 2 pages:

1. page1.aspx showing a single database record, with one of the rows in the detailsview a HyperLink row. This links to page2.aspx, with a Querystring of "id=", the value being the ID column of the displayed record. The single record that is shown is from a table called "tblBooks"

2. page2.aspx which I want to use to add a new record of data in a linked (but unrelated) table (tblAuthors - there can be any number of authors, hence another related table) to the one shown on page1.aspx.

What I want to do is get the querystring (Page.Request.QueryString("ID").toString) and feed it into the "BookID" field of the insert form on page2.aspx.

Firstly, is there an easier way that I am overlooking? If not, how do I get the BookID to be shown on page2.aspx, with the other 2 fields (Author first and last name) in insert mode?

Thanks in advance!!

Dominik.

Hello Dominik,

My suggestion is to use a business object to store and present your data. See the first 2 introduction tutorials onhttp://asp.net/learn/data-access/

After that you will have the feeling you stepped out of a time-machine and are light-years away from classic-ASP.

Jeroen Molenaar.


jeroenm:

My suggestion is to use a business object to store and present your data. See the first 2 introduction tutorials onhttp://asp.net/learn/data-access/

Wow, I wrote code behind a button, in the same way I would if designing a classic VB6-style application. That was after I created the dataset and associated Update, Insert, etc, functions in the designer. Very nice :-)

Thanks!

Dominik

0 comments:

Post a Comment