469,649 Members | 1,400 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,649 developers. It's quick & easy.

Unbound Access Data Source

I'm sure I'm missing something simple, but I've hit a brick wall. I'm
creating an ASP.NET 2.0 web site in VS2005 (VB.NET) and need to read data
from an Access database without attaching it to any UI control. I've dropped
an AccessDataSource control named AccessGetDescription on my aspx page and
configured the data source with an SQL SELECT statement. Now, how in code
do I loop through the returned records? Here's what I have so far:

Dim IEnum As IEnumerable
Dim ThisFile As String
Dim ???? As ????
ThisFile = "Whatever.xls"
With Me.AccessGetDescription
.SelectCommandType = SqlDataSourceCommandType.Text
.SelectCommand = "SELECT Description FROM TableName WHERE FileName =
ThisFileName"
.SelectParameters.Add("ThisFileName", ThisFile)
IEnum = .Select(DataSourceSelectArguments.Empty)
For Each ???? In ????
MyDesc = ???.Fields("Description").ToString()
Next ???
End With

What goes after the .Select method and how are the variables declared to
loop through all the records? I'm used to ADO where you can do a

Do Until RecSet.EOF()
Debug.Print RecSet.Fields("Whatever").Value
RecSet.MoveNext
Loop

I can't get this to work in ASP.NET 2.0.

Any suggestions would be greatly appreciated. Thank you very much.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

Jul 3 '07 #1
6 2899
"Chip Pearson" <ch**@cpearson.comwrote in message
news:91**********************************@microsof t.com...
Do Until RecSet.EOF()
Debug.Print RecSet.Fields("Whatever").Value
RecSet.MoveNext
Loop
Are you trying to use ADO instead of ADO.NET...?

If you're not doing any databinding, I would strongly advise not using any
of the DataSource objects at all.

Instead, just use ADO.NET to fetch a DataSet from your Jet database...
http://www.asp101.com/articles/jay/adodotnet/part3.asp
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 3 '07 #2
>Do Until RecSet.EOF()
> Debug.Print RecSet.Fields("Whatever").Value
RecSet.MoveNext
Loop

Are you trying to use ADO instead of ADO.NET...?
That code was just an example of what I am used to doing (in VB6 and VBA),
not what I'm doing now. Yes, I'm using ADO.NET. The link you posted was
interesting, but it still relied on binding the data source to a control, in
this case the DataGrid. I do NOT want to bind to any control. All I want to
do is a FOR loop iterating through the returned records one at a time,
examining the various fields of each record.

I would be very grateful if you could post some working code that iterates
through the result records of a SELECT without (!) binding to any control.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:e%****************@TK2MSFTNGP05.phx.gbl...
"Chip Pearson" <ch**@cpearson.comwrote in message
news:91**********************************@microsof t.com...
>Do Until RecSet.EOF()
Debug.Print RecSet.Fields("Whatever").Value
RecSet.MoveNext
Loop

Are you trying to use ADO instead of ADO.NET...?

If you're not doing any databinding, I would strongly advise not using any
of the DataSource objects at all.

Instead, just use ADO.NET to fetch a DataSet from your Jet database...
http://www.asp101.com/articles/jay/adodotnet/part3.asp
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jul 4 '07 #3
"Chip Pearson" <ch**@cpearson.comwrote in message
news:18**********************************@microsof t.com...
>>Do Until RecSet.EOF()
Debug.Print RecSet.Fields("Whatever").Value
RecSet.MoveNext
Loop

Are you trying to use ADO instead of ADO.NET...?

That code was just an example of what I am used to doing (in VB6 and VBA),
not what I'm doing now. Yes, I'm using ADO.NET. The link you posted was
interesting, but it still relied on binding the data source to a control,
in this case the DataGrid. I do NOT want to bind to any control. All I
want to do is a FOR loop iterating through the returned records one at a
time, examining the various fields of each record.

I would be very grateful if you could post some working code that iterates
through the result records of a SELECT without (!) binding to any control.
There are *heaps* of examples of how to do this in MSDN and on Google etc,
but...

string strConnectionString = "<...connection string to your Jet
database...>";
string strSQL = "<...SELECT * FROM Table WHERE This = That...">;
using (OleDbConnection objOleDbConnection = new
OleDbConnection(strConnectionString))
{
objOleDbConnection.Open();
using (OleDbCommand objOleDbCommand = new OleDbCommand(pstrSQL,
objOleDbConnection))
{
using (OleDbDataAdapter objDA = new
OleDbDataAdapter(objOleDbCommand))
{
using (DataSet objDataSet = new DataSet())
{
objDA.Fill(objDataSet);
objOleDbConnection.Close();
foreach (DataRow objRow in objDataSet.Tables[0].Rows)
{
// objRow["Field1"].ToString();
// objRow["Field2"].ToString();
// objRow["Field3"].ToString();
// etc
}
}
}
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 4 '07 #4
Please join me in congratulating Mark Rae, who was just named ASP.NET MVP
for the excellence and community spirit he has shown in his prolific,
and technically accurate, answers which have helped hundreds of frequenters
to the microsoft.public.dotnet.framework.aspnet newsgroup.

Congratulations, Mark !

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote
Jul 5 '07 #5
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Congratulations, Mark !
Aw shucks!

Gracias, jefe...

A sus ordines!
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 5 '07 #6
I'll join in the chant. I think Mark is a great addition to the community!

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
https://www.microsoft.com/MSPress/books/10933.aspx
OWC Black Book www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Please join me in congratulating Mark Rae, who was just named ASP.NET MVP
for the excellence and community spirit he has shown in his prolific,
and technically accurate, answers which have helped hundreds of
frequenters
to the microsoft.public.dotnet.framework.aspnet newsgroup.

Congratulations, Mark !

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote

Jul 5 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Stephan | last post: by
2 posts views Thread by Deborah V. Gardner | last post: by
3 posts views Thread by Dos Lil | last post: by
10 posts views Thread by Matthew Wells | last post: by
5 posts views Thread by SBC News Groups | last post: by
reply views Thread by chico_yallin | last post: by
6 posts views Thread by Volker Neurath | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.