|
-
Sep 2nd, 2002, 06:25 PM
#1
Thread Starter
Member
Sharing connections
Hi.
What is the best way to share a connection among multiple pages? I need to open a DataSet on one page for reading, but if my user needs to change the data, he will open another page with the selected data for editing. Is it possible?
Thanks,
Robert
-
Sep 3rd, 2002, 09:13 AM
#2
Lively Member
There is not really any way to do this on different pages using the same connection being that eash page is independently complied piece of code. As far as writng less code you could always make a com object too reuse code. That or you can edit and view data ont he same page. the data grid allows you to easily do this
"All those who wonder are not lost" -j.r.r tolkien
-
Sep 3rd, 2002, 11:24 AM
#3
you are going about it the wrong way. when someone selects a record to edit, you pass an id, or other identifier for the record, to the other page via a querystring, cache object, varaible, etc. Then you open a new connection to the databse using an sql statement that gets the record. You NEVER ,,,EVER keep a database connection open across pages. Do not even attempt to keep finding out how as any good programmer will tell you the same thing.
-
Sep 3rd, 2002, 11:56 AM
#4
Hyperactive Member
you are going about it the wrong way. when someone selects a record to edit, you pass an id, or other identifier for the record, to the other page via a querystring, cache object, varaible, etc. Then you open a new connection to the databse using an sql statement that gets the record. You NEVER ,,,EVER keep a database connection open across pages. Do not even attempt to keep finding out how as any good programmer will tell you the same thing.
I Agree....
..::[ kleptos]::..
- Database Administrator (MSSQL 2000)
- Application Developer (C#)
- Web Developer (ASP.NET)

-
Sep 3rd, 2002, 12:56 PM
#5
Thread Starter
Member
Hi Chris.
I understand what you say. My customer wants a grid to list the records, but wants to edit them on another page. I have a DataReader to fill the grid, so your advice is to pass an ID of the selected record to the new page and open my DataSet there, is it?
Thanks,
Robert
-
Sep 3rd, 2002, 01:11 PM
#6
yes that is it exactly. You can pass it to the next page using a querystring and get the value using request.querystring. Then just build your SQL statement to pull, update, edit, etc. whatever record has that 'id'. I assume you have some kind of unique identifier for your records.
just in case you dont know about querystrings.
Add a querystring to a url:
http://yousite.com/mypage.aspx?id=whatever
then use Request.Querystring("id") to get that value.
-
Sep 3rd, 2002, 03:04 PM
#7
Thread Starter
Member
Thanks Chris.
Robert Scheer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|