Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Unbound Access Data Source

Reply
Thread Tools

Unbound Access Data Source

 
 
Chip Pearson
Guest
Posts: n/a
 
      07-03-2007
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)

 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      07-03-2007
"Chip Pearson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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

 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      07-04-2007
>> 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" <(E-Mail Removed)> wrote in message
news:e%23s$(E-Mail Removed)...
> "Chip Pearson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-04-2007
"Chip Pearson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>>> 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

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      07-05-2007
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]" <(E-Mail Removed)> wrote


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-05-2007
"Juan T. Llibre" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> Congratulations, Mark !


Aw shucks!

Gracias, jefe...

A sus ordines!


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      07-05-2007
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting unbound ListView data values David C ASP .Net 0 11-10-2009 02:22 PM
What control would you use to display unbound data? Mel ASP .Net 15 10-29-2008 05:49 PM
how to get data to unbound control Barbara Schmidt ASP .Net 0 06-27-2006 08:46 PM
access textbox values that are unbound in datagrid .NetNewbie ASP .Net Datagrid Control 1 07-25-2005 05:14 PM
Unbound tables or grids of data? Barry ASP .Net 0 07-23-2003 04:15 PM



Advertisments