Welcome to WebmasterWorld Guest from 54.162.226.212

Forum Moderators: ocean10000

Message Too Old, No Replies

Simple data access via code

asp.net 2.0

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

10+ Year Member



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?

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

5+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month