Server Error in '/' Application.

A

A P

Whats wrong with my code?

<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'


Function GetDetails() As System.Data.DataSet
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\DBs\"&
_
"\db.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [tblmain].[DID],
[tblmain].[DDField], [tblmain].[SNo], [t"& _
"blmain].[DateFound] FROM [tbloprtrmain] WHERE ([tb"& _
"lmain].[Cancel] <> ""1"")"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then
DropDownList2.DataTextField = "DDField"
DropDownList2.DataSource = GetDetails()
DropDownList2.DataBind()
End If

End Sub

Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
DataList1.DataSource =
GetDPRDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
DataList1.DataBind()
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<font face="Arial"><strong>Show Details</strong></font>
</p>
<p>
<table>
<tbody>
<tr>
<td>
<p>
</p>
</td>
<td>
<asp:DropDownList id="DropDownList2"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></asp:DropDownLi
st>
</td>
</tr>
</tbody>
</table>
</p>
<!-- Insert content here -->
<p>
&nbsp;
<asp:DataList id="DataList1" runat="server">
<ItemTemplate>
Date Found: <asp:Label id="Label1" runat="server"
text='<%# DataBinder.Eval(Container.DataItem, "DateFound") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
</p>
</form>
</body>
</html>

it has an error:

Server Error in '/' Application.
----------------------------------------------------------------------------
----

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30367: Class 'System.Data.DataSet' cannot be
indexed because it has no default property.

Source Error:



Line 37:
Line 38: Sub DropDownList2_SelectedIndexChanged(sender As Object, e As
EventArgs)
Line 39: DataList1.DataSource =
GetDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
Line 40: DataList1.DataBind()
Line 41: End Sub

I've tried disabling the dropdownlist2_selectedIndexChanged and the dropdown
values worked, only when binding on datalist.

Pleae help.

Me
 
A

A P

never mind my question. I already solve it. Thanks anyway.
A P said:
Whats wrong with my code?

<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'


Function GetDetails() As System.Data.DataSet
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\DBs\"&
_
"\db.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [tblmain].[DID],
[tblmain].[DDField], [tblmain].[SNo], [t"& _
"blmain].[DateFound] FROM [tbloprtrmain] WHERE ([tb"& _
"lmain].[Cancel] <> ""1"")"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then
DropDownList2.DataTextField = "DDField"
DropDownList2.DataSource = GetDetails()
DropDownList2.DataBind()
End If

End Sub

Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
DataList1.DataSource =
GetDPRDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
DataList1.DataBind()
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<font face="Arial"><strong>Show Details</strong></font>
</p>
<p>
<table>
<tbody>
<tr>
<td>
<p>
</p>
</td>
<td>
<asp:DropDownList id="DropDownList2"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></asp:DropDownLi
st>
</td>
</tr>
</tbody>
</table>
</p>
<!-- Insert content here -->
<p>
&nbsp;
<asp:DataList id="DataList1" runat="server">
<ItemTemplate>
Date Found: <asp:Label id="Label1" runat="server"
text='<%# DataBinder.Eval(Container.DataItem, "DateFound")
 
X

xzzy

try these or a google search:

http://support.microsoft.com/default.aspx?kbid=829888

http://wss.collutions.com/Lists/FAQ/DispForm.aspx?ID=223

http://dotnetjunkies.com/WebLog/warstar/archive/2004/07/09/18752.aspx


John Bickmore
www.BuyYourInkNow.com

A P said:
never mind my question. I already solve it. Thanks anyway.
A P said:
Whats wrong with my code?

<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'


Function GetDetails() As System.Data.DataSet
Dim connectionString As String =
"Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\DBs\"&
_
"\db.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [tblmain].[DID],
[tblmain].[DDField], [tblmain].[SNo], [t"& _
"blmain].[DateFound] FROM [tbloprtrmain] WHERE ([tb"& _
"lmain].[Cancel] <> ""1"")"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

Sub Page_Load(Sender As Object, E As EventArgs)

If Not Page.IsPostBack Then
DropDownList2.DataTextField = "DDField"
DropDownList2.DataSource = GetDetails()
DropDownList2.DataBind()
End If

End Sub

Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
DataList1.DataSource =
GetDPRDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
DataList1.DataBind()
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<font face="Arial"><strong>Show Details</strong></font>
</p>
<p>
<table>
<tbody>
<tr>
<td>
<p>
</p>
</td>
<td>
<asp:DropDownList id="DropDownList2"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></asp:DropDownLi
st>
</td>
</tr>
</tbody>
</table>
</p>
<!-- Insert content here -->
<p>
&nbsp;
<asp:DataList id="DataList1" runat="server">
<ItemTemplate>
Date Found: <asp:Label id="Label1" runat="server"
text='<%# DataBinder.Eval(Container.DataItem, "DateFound")
%>'> said:
</ItemTemplate>
</asp:DataList>
</p>
</form>
</body>
</html>

it has an error:

Server Error in '/' Application.
--------------------------------------------------------------------------
--
----

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30367: Class 'System.Data.DataSet' cannot be
indexed because it has no default property.

Source Error:



Line 37:
Line 38: Sub DropDownList2_SelectedIndexChanged(sender As Object, e As
EventArgs)
Line 39: DataList1.DataSource =
GetDetails(DropDownList2.Items(DropDownList2.SelectedIndex).Text)
Line 40: DataList1.DataBind()
Line 41: End Sub

I've tried disabling the dropdownlist2_selectedIndexChanged and the dropdown
values worked, only when binding on datalist.

Pleae help.

Me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top