Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 3rd, 2004, 09:04 PM
Authorized User
 
Join Date: Jun 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using datasets, some code questions

Hi there, new to ASP.NET, been using ASP for years. Anyway, working on building an app in ASP.NET and running into some questions about datasets. Here is my code:

Code:
        Dim dstCustomers As DataSet
        Dim conMVP as SqlConnection
        Dim dadCustomers as SqlDataAdapter
        Dim strCustomersSQL as String

        dstCustomers = New DataSet()
        conMVP = New SqlConnection("server=ENVWDB;uid=web;pwd=xxx;database=xxx;")
        strCustomersSQL = "SELECT customer, name) FROM TSE...customers"
        dadCustomers = New SqlDataAdapter( strCustomersSQL, conMVP )
        dadCustomers.Fill( dstCustomers, "customer")

        dropCustomers.DataSource = dstCustomers
        dropCustomers.DataTextField = "customer"
        dropCustomers.DataBind()


Ok, so the first part that I'm having trouble with is:

dadCustomers = New SqlDataAdapter( strCustomersSQL, conMVP )

Here I'm in effect setting up a way to pull the return of my SQL statement from SQL Server correct?

dadCustomers.Fill( dstCustomers, "customer")

Now this is where the real confusion comes for me... I'm filling my dataset with the return from my query, but what is "customer"? The name of the table I'm putting it into in the dataset? The name of the the column of data I want to put into it? I thought the latter, but then I shouldn't be able to do this:

Response.Write( dstCustomers.Tables("customer").Rows(1)("name").To String() )

The whole query is getting put into it... so obviously I'm confused and missing something.

I suspect this is an easy one, if someone could set me straight it would be much appreciated.

Pat
 
Old November 4th, 2004, 10:47 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Hi,

  To answer your question about this line of code:
dadCustomers.Fill( dstCustomers, "customer")

Customer is the table name you are using that will be filled with the result of your query.

 
Old November 4th, 2004, 02:36 PM
Authorized User
 
Join Date: Jun 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Makes sense now -- thanks for your help.
 
Old November 4th, 2004, 03:45 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

no problem :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
hand code for datasets greenbriar BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 May 1st, 2008 05:42 AM
Find five Datasets rosejeep SQL Server 2000 1 November 9th, 2006 08:44 AM
Datasets Louisa VB.NET 2002/2003 Basics 1 October 6th, 2004 07:38 AM
DataSets CodeMonkeys C# 1 September 7th, 2004 09:48 PM
Code Download Questions Ben Horne Forum and Wrox.com Feedback 18 April 21st, 2004 09:52 AM





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