Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 23rd, 2005, 12:08 PM
Registered User
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP.NET Databases Using VB.NET

Dear all,

Can anyone points out where I am doing wrong. I have it over The comRadiobuttonList example (p.113)

When I select radiobutton of employee ex. "Davilio" in browser, I get the following error in debugger:

"The column prefix radEmployees.SelectedItem does not match with a table alias name used in query".

Other findings:
In IDE (Matrix), Design Tab: The radEmployees web control(asp:RadioButtonList) shows "Unbound".

Versions used:
                .Net Framework: 1.1
                Internet Explorer 6.0
                Database: MSDE with sp3
                Web Server: Web Matrix, version 0.6
                O/S: Windows 2000
                Database used:(SQL-Northwind, Employees DB)
                Code used: Same as in your example pp 113-114-115.

What I have already checked:
- My strSQL query: "SELECT TitleOfCourtesy, FirstName, LastName, Country, Region, City, Notes FROM Employees WHERE EmployeeID=lbxEmployees.SelectedItem.Value"
-The ID of my webcontrol is indeed: "lbxEmployees"'
-ExecuteReader() method is called after the connection is open.
-Connection syntax is seemingly good since i can display the data of Employees Table if I do not use the RadioButtonList web control.
-Data Environment of WebMatrix shows that there is a connection to Northwind DB on local.
-Connection to this database works as expected when displaying data in a datagrid (that is without eventhandler).
-Employees DB has a column "Employees ID" and a column "LastName"
Values "Davilio" en "1" are indeed in the table.

Looking forward to some coaching on this,
Christiane, The Netherlands

Old January 23rd, 2005, 12:27 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi Christiane,

You need to concatenate the value of the selected item to your SQL string. Right now, you're just passing the text lbxEmployees.SelectedItem.Value to the SQL statement.

Try this instead (all on one line):

"SELECT TitleOfCourtesy, FirstName, LastName, Country, Region, City,
  Notes FROM Employees WHERE EmployeeID = " &

Is EmployeeID a number? If it's not, you probably need to surround it by quotes:

"SELECT TitleOfCourtesy, FirstName, LastName, Country, Region, City,
  Notes FROM Employees WHERE EmployeeID = '" &
  lbxEmployees.SelectedItem.Value & "'"



Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Distegration by The Cure (Track 10 from the album: Disintegration) What's This?
Old January 23rd, 2005, 02:27 PM
Friend of Wrox
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post

it's better to use SqlParameters in your statement.

software engineering student.
Looking for a good job for summer 2005.

Similar Threads
Thread Thread Starter Forum Replies Last Post
vb.net 2008 re: VB.NET databases book bigbearjeff VB.NET 0 June 2nd, 2008 01:22 PM
Need help with databases in ASP.NET 2.0 dschips ASP.NET 2.0 Basics 1 March 3rd, 2007 11:57 PM
ISBN: 0-7645-6800-0 :Beginning VB.NET Databases Aiking BOOK: Beginning VB.NET Databases 1 July 11th, 2006 09:37 AM
WROX's Beginning VB.Net Databases by Thearon PeterRen BOOK: Beginning VB.NET Databases 3 March 16th, 2005 06:39 AM
Beginning ASP.Net Databases Using VB.Net ISBN 6195 tlamazares SQL Server ASP 1 December 15th, 2003 01:28 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.