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
|