Quote:
quote:Originally posted by planoie
This sounds like some kind of database/os configuration problem.
|
but for another code its work!
here is the working code:
I don't know why that code work, while my code being punished by the server
Code:
<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Oledb" %>
<script runat="server">
Sub Page_Load()
Dim strConnection as String = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnection &= "Data Source=" & Server.MapPath("Northwind.mdb")
data_src.text = strConnection
application("strConnection")=strConnection
Dim strSQL as string = "select FirstName, LastName from Employees"
Dim strResultsHolder as string
Dim objConnection as New OledbConnection(application("STRConnection"))
Dim objCommand as New OledbCommand(strSQL, objConnection)
Dim objDataReader as OledbDataReader
try
objConnection.Open()
con_open.text="Connection opened successfully.<br />"
objDataReader = objCommand.ExecuteREader()
Do While objDataReader.Read()=True
strResultsHolder +=objDataREader("FirstName")
strResultsHolder +=" "
strResultsHolder +=objDataREader("LastName")
strResultsHolder +="<br>"
Loop
objDataReader.Close()
objConnection.Close()
con_close.text="Connection closed.<br>"
divListEmployees.innerHTML = strResultsHolder
catch e as Exception
con_open.text="Connection failed to open successfully.<br>"
con_close.text=e.ToString()
end try
end Sub
</script>
<html>
<head>
</head>
<body>
<h4>Reading data from the connection <asp:Label id="data_src" runat="server"></asp:Label>with
the DataReader object.
</h4>
<asp:Label id="con_open" runat="server"></asp:Label>
<br />
<div id="divListEmployees" runat="server">list will go here
</div>
<asp:Label id="con_close" runat="server"></asp:Label>
<br />
</body>
</html>
For question asking, please made sure that your question is as similar as possible while providing enought level of details!
Since not all peoples, like to read large amounts of text just for reading or requirement and waste the answer time to read your text