 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 10th, 2007, 11:50 PM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Help.Can i use ADODB.Connection with DetailsView?
Hello,
How to bind DetailsView with d/b using ADODB.Connection?
Please help me out in this matter.I would be eagerly waiting for positive responses...
Thanks,
Aekta
|
|

March 11th, 2007, 03:48 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You could create a custom class that exposes your data as properties. Then you can have a method, like GetItem in that class that uses your connection through COM Interop to get the data, fill the properties and return the object.
Finally, you can connect your DetailsView to your own class through an ObjectDataSource control.
AFAIK, there are no direct ways to use ADODB.Connection objects in your pages.
But why would you want to do this? Why do you have a need to use an ADODB.Connection?
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

March 11th, 2007, 05:26 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for ur reply.I have already bind data from SQl Server d/b with DetailsView Dynamically by using OledbConnection.
Example:
ID of DetailsView is d1,I execute the sql query using Executereader.Then,d1.Datamember="name"(where "name" is a field in table of d/b).Then i bind it using d1.databind().It only displayed me one record from d/b.
Can u please tell me how to display all the records from d/b.Remember,I waNT IT DYNAMICALLY.
If possible then explain me through example.
Thanks,
Aekta
|
|

March 11th, 2007, 05:31 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The DetailsView shows one record at a time. This is by design. You can page through the data if you want.
You may want to look at the GridView instead.
This isn't really about using the ADODB.Connection, is it??
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

March 11th, 2007, 05:43 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yaa.. that's true.I can use GridView to display records.But How could i do update,delete,add operations in DetailsView dynamically.bcoz...i could not put any loops as Executereader() will execute my query.can u suggest me how to do it?This is very important part of my project.
|
|

March 11th, 2007, 06:08 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Controls like DetailsView work best with *DataSource controls, like the SqlDataSource or the ObjectDataSource. Usually you define methods or SQL statements for insert, update and other CRUD methods.
However, if your SQL is dynamic you can't really use them as is. The SqlDataReader is read-only, forward only. So, although you can use it to build up a DetailsView on the fly, you can't use it for updates.
Instead, you should somehow handle the Inserting / Updating events, get references to the controls inside your DetailsView and then manually construct a SQL statement for the insert / update.
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|
 |