homepage Welcome to WebmasterWorld Guest from 54.242.231.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Simple data access via code
asp.net 2.0
mcavill




msg:944645
 11:46 am on Jun 15, 2006 (gmt 0)

I'm trying to learn a bit of asp.net 2.0 and am having problems getting my head around the AccessDataSource control.

I'm trying to get a single field out of the table.

The row looks something like: ID (int), Role(string)

So I have my AccessDataSource all configured up to point at the DB, which all looks good in the previews etc.

In the code I have tried:

myVariable = 1
AccessDataSource1.SelectCommand = "SELECT [Role] FROM [tbl_standard_roles] WHERE ([ID] = " & myVariable & ")"
myRole = AccessDataSource1.Select(DataSourceSelectArguments.Empty)

no luck, so I tried:


myVariable = 1
AccessDataSource1.SelectCommand = "SELECT [Role] FROM [tbl_standard_roles] WHERE ([ID] = " & myVariable & ")"
Dim dv As Data.DataView = AccessDataSource1.Select(DataSourceSelectArguments.Empty)
myRole = dv.ToTable.Rows(0)(1).ToString

again no luck.

The AccessDataSource1.Select just doesn't seem to be returning anything - there's definitely a record with 1 as the ID - so I'm at a complete loss as to how to access data, I'm assuming there is a way getting back a recordset from the AccessDataSource control? or do I need to go back to the old DataSets, etc?

 

oxbaker




msg:944646
 5:50 pm on Jun 15, 2006 (gmt 0)

i havn't used this data source but are you sure your SQL is well formed. Do you NEED the square brackets around the field and table names. I only ask this because with the normal SQLConnection objects in .net you just write sql like this.

select fieldname from table;

no square brackets.

hth,
mcm

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved