-
DB Connectivity Problem
Hi
I am trying to display MS Access Data thru aspx page. But getting errors.
Code is as follows :
------------------------------------------------------------------------------------
<%@ Page Language="vb" Debug="true" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
'declarations
Dim conTest As OleDbConnection
Dim cmdTest As OleDbCommand
Dim rdrTest As OleDbDataReader
conTest = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\TestNet.mdb")
conTest.Open
cmdTest = New OleDbCommand ( "select * from Emp", conTest)
rdrTest = cmdTest.ExecuteReader
gridTest.DataSource = rdrTest
gridTest.DataBind
rdrTest.Close
cmdTest.Dispose
conTest.Close
End Sub
</script>
<html>
<head>
<title>Test of dot net for database connections - uses Test</title>
</head>
<body text="#000000" bgcolor="#ffffff">
<h1>Listing from Test accounts using dot net
</h1>
<asp:DataGrid id="gridTest" accessKey="<%# Page %>" runat="server" itemstyle-verticalalign="top" headerstyle-font-bold="true" headerstyle-backcolor="lightsteelblue" autogeneratecolumns="false" font-size="8pt" cellpadding="5" width="92%">
<columns>
<asp:boundcolumn headertext="Emp No." datafield="EmpNo" />
<asp:boundcolumn headertext="Emp Name" datafield="EmpName" />
<asp:boundcolumn headertext="Dept." datafield="DeptNo" />
<asp:boundcolumn headertext="Salary" datafield="Salary" />
</columns>
</asp:DataGrid>
</body>
</html>
------------------------------------------------------------------------------------
Errors are as follows :
------------------------------------------------------------------------------------
Specified argument was out of the range of valid values.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: value
Source Error:
Line 32: <h1>Listing from Test accounts using dot net
Line 33: </h1>
Line 34: <asp:DataGrid id="gridTest" accessKey="<%# Page %>" runat="server" itemstyle-verticalalign="top" headerstyle-font-bold="true" headerstyle-backcolor="lightsteelblue" autogeneratecolumns="false" font-size="8pt" cellpadding="5" width="92%">
Line 35: <columns>
Line 36: <asp:boundcolumn headertext="Emp No." datafield="EmpNo" />
Source File: c:\inetpub\wwwroot\NewFile.aspx Line: 34
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value]
System.Web.UI.WebControls.WebControl.set_AccessKey(String value) +96
ASP.NewFile_aspx.__DataBindgridTest(Object sender, EventArgs e) in c:\inetpub\wwwroot\NewFile.aspx:34
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +10
System.Web.UI.WebControls.BaseDataList.DataBind() +23
ASP.NewFile_aspx.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\NewFile.aspx:20
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
------------------------------------------------------------------------------------
Please kindly suggest solution.
Thanks and Regards
Mahesh
-
pretty sure you can't do this:
Code:
accessKey="<%# Page %>"
, take it out and see if it works. Why were you putting that in there?
-
Hi pvb
That MS Access connetivity worked using following code.
Sub Page_Load(sender As Object, e As EventArgs)
Dim conTest As OleDbConnection
Dim cmdTest As OleDbCommand
Dim rdrTest As OleDbDataReader
conTest = New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\TestNet.mdb")
conTest.Open
cmdTest = New OleDbCommand ( "select * from Emp", conTest)
rdrTest = cmdTest.ExecuteReader
gridTest.DataSource = rdrTest
gridTest.DataBind
rdrTest.Close
cmdTest.Dispose
conTest.Close
End Sub
But now facing SQL Server connectivity problem.
Pls kindly refer to new thread
http://www.vbforums.com/showthread.p...hreadid=283807
Thanks
Mahesh