Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics 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 November 4th, 2008, 03:25 PM
Authorized User
 
Join Date: Mar 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default asp.net / sql help needed

I have a simple SQL database that contains a list of records (instructor/class/date/and a series of likert scores).

I want to run a web front end...connect a SQLDataSource to the SQL database...and drop onto the aspx page a series of web controls (dropdown lists to choose instructor and/or class, calendar controls to choose date ranges)...to ultimately customize parameterized queries off the SQL database.

What book(s) do I need?

I have little experience coding in any language - though i'm becoming more and more proficient in Visual Studio...





 
Old November 4th, 2008, 04:08 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Sounds like you could use a copy of Beginning ASP.NET 3.5: http://www.wrox.com/WileyCDA/WroxTit...47018759X.html

Besides the SqlDataSource control and accessing SQL Server, this book teaches you a lot more on ASP.NET. All code and explanation is in two languages: C# and Visual Basic .NET.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 4th, 2008, 04:47 PM
Authorized User
 
Join Date: Mar 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply!

Actually, I have your book. It's made me sufficiently dangerous. ;)

So, in taking your example found in Ch12 (Filtering Data), I could simply set up WHERE clauses for both the instructor (dropdown) and course (dropdown)? Will the 'Add WHERE Clause' dialog box allow you to stack multiple filters to ultimately build parameterized queries on the fly like this?

Thanks!

 
Old November 4th, 2008, 04:59 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, exactly. The WHERE dialog allows you to specify multiple parameters, like controls, that are used in the WHERE clause.

This way, you could have a number of controls like Drop downs drive the query.

Hope this helps.

Having fun with the book?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 4th, 2008, 05:08 PM
Authorized User
 
Join Date: Mar 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can I bind the clauses i create in that WHERE dialog box to a SQL statement I've already configured to my SQLDataSource object?

I've got a SQL table with a few thousand records. Several of the fields are 'scores', so 'AVG' is sent back. I assume then the AVG would be sent back off the WHERE parameters.

I love the book. I'm still trying to learn to 'think' in .net. That, besides well actually learning coding (!), is the key, in my opinion.

 
Old November 4th, 2008, 05:16 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, but not so easily. The WHERE build only works when you select columns from a table.

Two solutions I can think of:

1. Create a SQL View over your table and alias your columns as you see fit. VWD then thinks it's a column and lets you use the WHERE clause builder.

2. Create parameters first using the WHERE builder. Then copy the source and keep it. Next, reconfigure the SqlDataSource and create a custom SQL statement. Then manually modify the statement and the parameters collection so they work together.

And yes, learn to code is very important. You only get so far with drag and drop, although I am always surprised at just how far you can get with that..... ;)

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 5th, 2008, 05:37 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What does your view look like? Is it parameterized?

And where do you get that dialog and under what circumstances? That is, what do you select as the table / query and what do you enter as the parameters?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 11th, 2008, 02:02 PM
Authorized User
 
Join Date: Mar 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the View I created (at the SQL database):

SELECT Instructor, Course, CourseDate, AVG(SessionFlow) AS SessionFlow, AVG(Materials) AS Materials, AVG(CBT) AS CBT
FROM dbo.Likert_Scores
GROUP BY Instructor, Course, CourseDate



As far as it being parameterized, In the SQLDataSource object (on aspx page) I configure it so that it specifies the View in the dropdown, and then check off the * for all columns. in the WHERE clause i attempt to run a SQL expression...

SELECT * FROM [Likert_View] WHERE ([Course] = @Course)

When I test the query, the Parameter Values Editor dialog box appears.

Thanks!

 
Old November 12th, 2008, 08:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, that makes sense doesn't it? It's a parameterized query, so in order to test it, you need to provide a value. Simple enter a valid Course and it should work...


Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old November 12th, 2008, 10:20 AM
Authorized User
 
Join Date: Mar 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, it does make sense and the test validates the query.

Do I need to bind the dropdown list to the Source in any other place (code, markup etc) otherwise?

In the WHERE clause, I've chosen the column 'Course', operator '=', Source 'Control', Control ID 'ddlCourse'.

I've got a dropdown named ddlCourse that has Select data source set as 'SQLDataSource1', ...field to display in DropDownList as 'Course', and ...value of the DropDownList as 'CourseID'.


I'm clearly missing a step because when I run this The databound dropdown does not populate, and the grid does not show up.

Thanks for your help!

Keith








Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 1.1,VB.NET,crystal reports, SQl server gvi Crystal Reports 1 September 11th, 2008 02:55 AM
ASP.Net Development Engineer needed lashan ASP.NET 2.0 Professional 0 January 7th, 2008 01:10 PM
Files needed to run ASP.NET? RAM req'd? Ron Howerton ADO.NET 1 February 15th, 2005 09:08 AM





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