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

You are currently viewing the ASP.NET 2.0 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 January 16th, 2006, 10:44 PM
Authorized User
 
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using stored procedures with datasets

Hello and thank you for taking a moment to read this message. I am simply trying to use a stored procedure to set up a dataset. for some reason when I try to fill the dataset with the data adapter I get the following error:

Compiler Error Message: BC30638: Array bounds cannot appear in type specifiers.
Line 86: ' Create the Data Adapter
Line 87: Dim objadapter As SQLDataAdapter(mycommand2, myconnection2)

my code looks as follows for the dataset:


<script runat="server">
Sub ListSongs()

    ' Dimension Variables in order to get songs
       Dim myConnection2 as SQLConnection
       Dim myCommand2 as SQLCommand
       Dim intID4 As Integer

    'retrieve albumn ID for track listings

            intID4 = Int32.Parse (Request.QueryString("id"))

     ' Create Instance of Connection

                myConnection2 = New SqlConnection( "Server=localhost;uid=jazzcatone;pwd=funkdafied;da tabase=Beatles" )
                myConnection2.Open()

      'Create Command object
                Dim mycommand2 AS New SQLCommand( "usp_Retrieve song_",objCon)
                mycommand2.CommandType = CommandType.StoredProcedure
                mycommand2.Parameters.Add("@ID", intID4)

    ' Create the Data Adapter (this is where my code fails, not really sure what to do)
         Dim objadapter As SQLDataAdapter(mycommand2, myconnection2)

    'Use the Fill() method to create and populate a datatable object into a dataset. Table will be called dtsongs
          Dim objdataset As DataSet()
          objadapter.Fill(objdataset, "dtsongs")

     'Bind the datatable object called dtsongs to our Datagrid:

            dgrdSongs.Datasource = objdataset.Tables("dtsongs")
            dgrdsongs.DataBind()
</script>
<html>
<head>
    <title>Albumn Details</title>
</head>
<body style="FONT: 10pt verdana" bgcolor="#fce9ca">
<center>
        <asp:DataGrid id="dgrdSongs" Runat="Server"></asp:DataGrid>
    </center>
</body>
</html>

Any help or advice would be greatly appreciated. Thank You - Jason

 
Old January 17th, 2006, 04:02 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is this related to ASP.NET 2.0 or ASP.NET 1.x? I see you're using a DataGrid which seems to suggest ASP.NET 1.x. but you're posting this in the 2.0 forum.

Anyway, use New to instantiate a new Adapter:

  Dim objadapter As New SqlDataAdapter(mycommand2, myconnection2)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
STORED PROCEDURES shazia1 SQL Server ASP 7 September 26th, 2007 06:11 AM
Stored Procedures itHighway SQL Server 2000 3 November 23rd, 2005 10:08 AM
Stored Procedures stu9820 ASP.NET 1.x and 2.0 Application Design 2 January 15th, 2005 04:09 AM
Using Stored Procedures lintacious Classic ASP Basics 1 August 12th, 2003 04:06 PM





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