Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 April 30th, 2005, 03:13 AM
Authorized User
 
Join Date: Apr 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default ADODB.Fields

A little problem which I can't seem to resolve. I'm using ADODB to loop out values from a database.

My connection is simple:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydb.mdb"
Connection.Open(ConnectionString)

Command.ActiveConnection = Connection.Open

Once the connection has been made I want to loop out the information contained in the table called "Surf"

Command.CommandText = "SELECT * FROM Surf"
Command.CommandTimeout = 10
Command.CommandType = ADODB.CommandTypeEnum.adCmdText

SQLString = Command.Execute

Now here is my problem:

In ASP it was fairly simple to loop out the required information by specifying which record in the table I want to display by doing the following:

variable1 = SQLString("Recordname")

and it would give me the correct value, but I'm trying to use the same type of connection in ASP.NET and keep on getting an error such as: "Value of type 'ADODB.Field' cannot be converted to 'String'".

Am I doing something wrong or is there a specific method I should use?

Any help would be appreciated

 
Old May 1st, 2005, 12:51 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I woulld fill a data set with the results from your query. Then loop through the dataset, getting each column in the table you need, and assign it to your respective variables.

 
Old May 2nd, 2005, 08:50 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Eric,

Why are you attempting to use ADODB in ASP.NET? Perhaps you need to read up a little on the new classes available in ADO.NET. There are classes for connecting to and retrieving data from various data sources such as the SqlConnection, SqlDataReader and SqlDataAdapter (for Access/JET you can use the OleDb flavor of these classes). Also there are several classes that are data-store agnostic that you can use to work with data in .NET such as DataTable and DataSet.

-Peter
 
Old May 4th, 2005, 02:24 AM
Authorized User
 
Join Date: Apr 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default

The reason for using adodb is because i developed the previous version with asp and i used adodb to connect. this worked perfectly, but seeing that i want to upgrade to the new .net standard i would like to keep my current connection as is. i will in due course update the entire app but for now only want to use what i have been doing so far.

But thanks for you help the correct method was specify the .value of the field i'm trying to loop out.

 
Old May 4th, 2005, 06:45 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by EricJ
 ...seeing that i want to upgrade to the new .net standard i would like to keep my current connection as is.

Isn't this a paradoxical statement? You're likely to run into more problems using ADODB in .NET then if you just move to ADO.NET (as you have found already). There isn't much to it. Indeed the ADO.NET objects (*DataReader, DataSet, DataTable) are much easier and more intuitive than the archaic RecordSet object.

I'm willing to bet that if you take a little time to learn about the new classes in ADO.NET your application conversion time and effort will be reduced. But that's up to you.

-Peter
 
Old May 5th, 2005, 03:02 AM
Authorized User
 
Join Date: Apr 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default

Quote:
quote:Originally posted by planoie
I'm willing to bet that if you take a little time to learn about the new classes in ADO.NET your application conversion time and effort will be reduced. But that's up to you.
I already know the language, but to make things easier for my students I like to grind them with what used to be, the old language. That way they actually understand why the new language came to be.

Thank you for your input on this matter, I must agree that switching to ADO.Net makes life must easier.

 
Old May 5th, 2005, 07:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Eric,

I hope your students drop your class and find another teacher that wants to teach them how things SHOULD be done- rather than filling their heads with the wrong way to do things first.

There is no value in "grind" them with the old way when the old way sucks.

Do the Industry a favor and teach them how to do it right- I see way too many people doing it the wrong way, and now I know why.


Hal Levy
I am here to help you, not do it for you.
That is, unless you hire me. I am looking for work.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to update using ADODB jmhemadri Classic ASP Databases 1 September 9th, 2008 06:07 PM
Can we Inherit ADODB venki5star Visual Studio 2005 3 March 13th, 2006 10:50 AM
Using Forum fields select fields on the fly hellosureshkumar Crystal Reports 0 December 17th, 2004 08:20 AM
How to get adodb.record from adodb.recordset John Pennington Pro VB Databases 1 November 20th, 2004 06:17 AM





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