Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
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
 
Old March 10th, 2007, 11:50 PM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old March 11th, 2007, 03:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old March 11th, 2007, 05:26 AM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old March 11th, 2007, 05:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old March 11th, 2007, 05:43 AM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old March 11th, 2007, 06:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB connection fails (better topic) halfnote5 Access 6 September 5th, 2007 09:35 PM
ADODB.Connection on every page? Steve777 Classic ASP Professional 10 September 13th, 2006 08:19 AM
ADODB.Connection (0x800A0E7A) sumanst Classic ASP Databases 1 August 5th, 2005 02:56 PM
ADODB connection for Recordset dpatole Beginning VB 6 1 October 14th, 2003 04:24 PM
ADODB Connection String misterqj Access 2 September 30th, 2003 06:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.