Converting ADO to ADO.NET

Hi, I am trying to convert this code from ADO to ADO.NET

I am very new to ADO.NET and am a bit confused on how I would convert this.
Basically what I am trying to do is capture the name of the fields of a table to populate a dropdownlistbox. The table name will change every time the program is run. This is not a problem and I can code for that.
Here is what I have in ADO (I have tried the wizard but it did not change the code)

Dim tblFields As Object
Dim myRst As New ADODB.Recordset
Dim myField As ADODB.Field
Dim myCnn As New ADODB.Connection
Dim cmdText As String
Dim cnnString As String
cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<database>;Persist Security Info=False"
With myCnn
.ConnectionString = cnnString
.Open()
End With

cmdText = "SELECT * FROM <table>"
myRst.Open(cmdText, myCnn)
tblFields = myRst.Fields
Dim TotalCount As Integer
TotalCount = tblFields.Count

For Each myField In tblFields
Debug.Print myField.Name
Next myField
myRst.Close()

This code works in VB6, but I really need it for an ASP.NET application. I want to get away from ADO and into ADO.NET
Any help would be greatly appreciated!
Thanks
0
millenniasp
12/4/2003 5:12:31 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

2 Replies
854 Views

Similar Articles

[PageSpeed] 23

There are way to many way to list how to do this. You could do it with a Reader or an Adapter, the usage would depend on what all you wanted to do with the data and if you wanted it disconnected or disposed. Yes ADO.Net is a completely different way of thinking about Data.

The only thing I can really do for you is give you a book to read.
ADO.Net Core Reference
Microsoft Press
Author David Sceppa
ISBN: 0-7356-1423-7
I ready the whole thing cover to cover in about 2 weeks. And it is by far the most excellent book on ADO.net forget about the ADO.net Step by Step it is useless All Code samples are in both VB.net and C#
0
BOUND4DOOM
12/4/2003 10:01:21 PM
Thanks for the tip on the book! I 'll be sure and pick it  up.

I did some "deep" digging around here and found some code snippets that were a big help. What I would phrase for a search would never have brought me to the thread where I found the results, but the digging sure paid off!
here is the end result (in case anyone else ever comes accross this problem)

Private Sub PopulateFields()
Dim strText
strText = txtTable.Text.ToUpper
txtTable.Text = strText
cnnAccess = New OleDbConnection(strCnnAccess)
cnnAccess.Open()
strTable = "["
strTable = strTable & txtTable.Trim
strTable = strTable & "]"
strCmdAccess = "SELECT TOP 5 " & strTable & ".* "
strCmdAccess = strCmdAccess & "FROM " & strTable & ";"
myDa = New OleDbDataAdapter(strCmdAccess, cnnAccess)
myDs = New DataSet
myDa.Fill(myDs, "AllFields")
Dim myDc As DataColumn
For Each myDc In myDs.Tables(0).Columns
cbo1.Items.Add(myDc.ColumnName)
cbo2.Items.Add(myDc.ColumnName)
cbo3.Items.Add(myDc.ColumnName)
Next
cnnAccess.Close()
cnnAccess.Dispose()
myDs.Dispose()
myDa.Dispose()

End Sub
0
millenniasp
12/5/2003 6:19:07 PM
Reply:

Similar Artilces:

Does .NET map calls for ADO to ADO.NET?
Hello,We are trying to troubleshoot some DB problems from COM objects that call ADO. I heard that when ADO is loaded inside of a COM object by a .NET app, that .NET intercepts the call and re-maps those calls over to ADO.NET. This seems untrue to me, given the nature of ADO.NET being a totally separate technology.Does anyone know for sure whether this does or does not occur?The problem we are seeing is actually almost identical in symptoms to this:http://support.microsoft.com/default.aspx/kb/230101"FIX: Data Queries Sporadically Return Empty Recordsets" Literally, this is what...

ADO in VB6 vs ADO.NET in VB.NET
I am writing a database interface and I would like to know whether a VB6 interface using ADO or a VB.NET interface using ADO.NET would be faster in terms of just performing database operations. Is there an explanation for this, and what is the magnitude of the difference? Thanks in advance!...

ADO to ADO.NET
I'm an ASP programmer (VBScript) moving on to ASP.NET. So far I'm using:Microsoft Visual Studio 2003ASP.NET with C#I'm working on converting my code over to C#, from VBScript. Now, here is my code in VBScript (modified to better understand it, this is a edited ugly version):Function ExecuteSQL(sqlStatement)    ConnDriver = "Provider=SQLOLEDB; Data Source = " & dbIP & "; Initial Catalog = " & dbName & "; User Id = " & dbUser & "; Password=" & dbPassword     Set connTemp = Server.CreateObject("ADODB.Connection")    c...

ADO not ADO.NET
Hi, I have to connect to a db using adodb (which i select from the references). I have to retrieve the car models from the database and bind them to a listbox. I am not sure how to proceed and I can't find any articles on ADO with .net and data binding. Here is the code that i tried but it only retrieves the car model for the specified id. If I delete the id it doesn't work. Also it writes the car model in the listbox vertically such as: B M W CODE: Imports System.Data Imports ADODB Imports System.Data.OleDb Public Class listboxADO Inherits System.Web.UI...

Converting .NET ADO Dataset to ADO Recordset
Hi Experts, I have a .NET dataset and I have to convert it to an ADO Recordset to call a method of an ocx because the parameter of this method is an ADO recordset. How can I do that ??? Here is my function where I have to convert Public Sub DisplayAgentStats() Dim objConnection As SqlConnection Dim objCommand As SqlDataAdapter Dim sConnStr As String Dim sSQL As String Dim ds As New DataSet() Dim ReturnCode As Integer sConnStr = "server=ServerA;database=DB1;uid=sa" sSQL = "sele...

ADO.NET Visual Studio 2005 Install Help!, ADO.NET Missing
 Hi everyoneI have a real annoying problem, I have installed Visual Studio 2005 with C#,C++,Web Applications.. Before I installed VS2005 I made sure I had all the .Net Download from 1.1 to 3.5 with the Service Packs, I also Installed a VS2005 Patch that was around 430mb. I have tried this on 3 computers, two of XP and 1 vista.I need ADO.NET Functionality, When I choose to create a Web Application in C#, I require the ADO.NET Entity Data Model as it will allow for a graphical interaction with a SQL db. However When I Choose Add New Item in Solution explorer there is no ENtity Mode...

Innovation to ADO.NET
Matisse Software Inc. provides its native ADO.NET Data provider for Matisse 6.0, the Database for .NET. Matisse Software has pushed the envelope of Microsoft ADO.NET architecture and extended it into a powerful Object Access Services component for .NET. Matisse’s extension of ADO.NET demonstrates that ADO.NET can evolve beyond the Microsoft architecture to benefit .NET developers. Unlike the standard ADO.NET data provider, which returns data in a table format to integrate seamlessly with relational products, Matisse has extended the ADO.NET architecture to return data in an object format....

ADO to ADO.NET help
Hi, I am converting application ASP to ASP.NET.What is the equivalent code in ADO.NET. For each F in RS.Fields FieldName = F.Name Next Thanks, Nate If it is forward only, then you can use datareader for more info on this, check below link Datareader on MSDN Hope it helps!Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti...

Opinions about ADO and ADO.NET
Hi everyone again!!! I´m used to develope applications with ADO, but now with .NET to develope a Web Application and a Mobile Web Application, I don't know if I have to use ADO.NET or continue using ADO. What Disadvantages has ADO to built Mobile Applications? In ADO I use ACCESS to create the .mdb files, Can I use .mdb files with ADO.NET? Thanks for all!! Go to ADO.NET NOW ! don't be late and you can use access in ado.net ADO.NET VB.NET/C#/ASP.NET/Oracle Designer 6i DotNet4Arab.com Building a custom web control(vb.net) Well, Thanks for your opinion, but I have...

ADO.NET VS ADO
Hi I am having ADO.NET course these days. I asked the instructor that developing online system like airline reservation system needs to a connected environment to lock/Unlock the table when u read/write to it Can that be acomplished using ado.net. His answer was no ADO.NET is only for disconnected environment and it will not work with online system and i still should use the old ADO. ADO.NET is not a replacment for ADO and both will continue in paralell. IS his answer true that ADO.NET will not replace ADO and both will continue Regards Check this link. Well ADO.NET is pa...

ado.net or/and datawindow.net
Hi, Can datawindow.net work with Sybase's ado.net or are they not compatible with each other. We have two separate groups of developers, one group develops web apps using ASE as the back end for the data, so they use a combination of Visual Studio ..NET and Sybase's ado.net to do their work. We have another group that develops client/server apps using Powerbuilder, but since 80% of their work is in writting reports using Powerbuilder, I was wondering if they could use a combination of datawindow.net and ado.net to put make these reports available on the web through ...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

Where is the ADO.NET Sybase driver for .NET 1.1 and .Net 2.0?
Hi All Does anyone know where I can get the Sybase drivers for ADO.NET for both versions, 1.1 and 2.0/3.0? Cheers Chris Burrell Hi Chris, There is no release of ASE ADO.NET Provider 2.0 (I assume you refer to ASE provider, not ASA - if ASA please port to sybase.public.sqlanywhere.general). For the 1.1 Provider: It is available in the ASE SDK for windows or the PC Client CDRom included with ASE product. On the SDK its available as 12.5.1 and 15.0 On ASE PC Client I think 12.5.1 is part of ASE 12.5.X and 15.0 is part of ASE 15.X 2.0 provider should release som...

ADO.NET equivalent to ADO recordset
I'm new to ASP.NET 2.0 and ADO.Net but have some experience with oldschool ASP and ADO :)My question is ADO.NET has an equivalent to ADO recordset?In normal ADO I use to read and compare database cells 1 set User= Server.CreateObject("ADODB.Recordset") 2 User_sql = "SELECT * FROM tblUsers WHERE UserName='" & Request.Form("UserName") & "'" 3 User.open User_sql, Conn 4 5 if User("Password") = Request.form("Password") then 6 Response.write(User("Password"))7 end if ...

Web resources about - Converting ADO to ADO.NET - asp.net.object-datasource

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: http://fora.tv/2010/07/29/Nomad_From_Islam_to_America_with_Ayaan_Hirsi_Ali Ayaan Hirsi Ali explains her support of missionary ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Rothesay building new arena, converting existing rink to fieldhouse
The Town of Rothesay plans to build a new arena and convert the existing one into a fieldhouse.

Resources last updated: 1/5/2016 9:21:45 AM