473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

AccessDataSource Select Command

In VS'05 I have an aspx page with a label that I am trying to populate from
a field (Last) in table (Ante_Pedigree) from an Access database.

In C# in a code-behind I run:

AccessDataSource AccessDataSource2 = new AccessDataSource();
AccessDataSource2.DataFile =
System.Configuration.ConfigurationManager.AppSetti ngs["ConnString"];
Parameter Param = new Parameter("AnteNum");
Param.DefaultValue = fileid;
AccessDataSource2.SelectParameters.Add(Param);
AccessDataSource2.SelectCommand = "SELECT Last FROM Ante_Pedigree Where
AnteNum=@Param";
LabelFileNum.Text =
AccessDataSource2.Select(DataSourceSelectArguments .Empty).ToString();

The result is that LabelFileNum.Text = System.Data.DataView

What am I doing wrong; I am obviously using an advanced feature when all I
want to do is retrieve a value.

Thanks in advance for your help.

Jim


Apr 16 '06 #1
1 14094
The ToString() method is returning System.Data.DataView because that is
the type of the object returned by the Select member of
AccessDataSource .

You may need to cast to a DataView to then retrieve the record you
need:

LabelFileNum.Text =
((DataView)AccessDataSource2.Select(DataSourceSele ctArguments.Empty))[0]["Last"].ToString();

Hope this helps.

Apr 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: msnews.microsoft.com | last post by:
I've got a paging and sorting enabled GridView whose datasource is and AccessDataSource. I build the SelectCommand at PageLoad - it's a union query to show items and comments of the user logged...
4
by: Luqman | last post by:
How can I display any field value in textbox of sqldatasource using VS.Net 2005 ? Say : Dim x as new AccessDataSource X.connectionstring="Data source="D:\mydb.mdb" X.Selectcommand="Select...
0
by: Luqman | last post by:
How can I display any field value in textbox of sqldatasource using VS.Net 2005 ? Say : Dim x as new AccessDataSource X.connectionstring="Data source="D:\mydb.mdb" X.Selectcommand="Select...
0
by: Jim McGivney | last post by:
In Using VWD I have found it very easy to associate an Access Database with gridview and detailsview controls to view and manipulate data. There are times when I need to programmatically obtain...
1
by: mosscliffe | last post by:
I am trying to filter an accessdatsource by adding a FilterExpression If I have Field = 2 It works fine If I have Field IN (1,5,7) it works fine So now I want it to reference a...
0
by: DC | last post by:
Why would this code give me the error "Could not load type System.Web.UI.WebControls.AccessDataSource from assembly System.Web, Version=1.0.5000.0" at line 16... <form id="form1"...
4
by: msch-prv | last post by:
I use an Access db in my application. So far I have been exclusively working wtih the AccessDataSource controls to hook up to the db. I know that Access db connections can also be established with...
0
by: mlfblom | last post by:
Hi, I know I am not the only one struggling with the following, but so far I have not seen a solution. Problem: I have an asp.net 2.0 web page with a gridview which is bound to an...
2
by: dorandoran | last post by:
I got this from http://www.codeproject.com/KB/aspnet/EditNestedGridView.aspx. I dont like using accessdatasource. What are my option? (what I really like is to create a class and create object in...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.