Hier mal der komplette sourcecode:
<%@Page Language="C#" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Globalization" %>
<script language="C#" runat="server">
protected DateTime today=DateTime.Today;
public String SQL;
public void ListObjects()
{
//Path to Database
string path =
HttpContext.Current.Request.MapPath("database//data.mdb");
//initialize OleDB Connection
OleDbConnection oConn = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" + path);
//Initialize OleDBReader
OleDbDataReader myReader = null;
SQL = "SELECT * FROM objects WHERE ObjectTimeStamp >= " +
today.AddDays(-2).ToString("yyyyMMdd") + " ORDER BY ObjectTimeStamp
DESC";
try
{
//open OleDB Connection
oConn.Open();
//Set SQL-Statement in OleDBCommand
OleDbCommand oCmd = new OleDbCommand(SQL, oConn);
//Fill Reader with OleDB Command
myReader = oCmd.ExecuteReader();
//Loop though Reader and Write
while (myReader.Read())
{
HttpContext.Current.Response.Write(myReader.GetString(1) + " - " +
myReader.GetDateTime(18) + "<br>");
}
}
catch (Exception MyErr)
{
string err = MyErr.ToString();
string[] errArray = err.Split(new Char[] {'\n'});
HttpContext.Current.Response.Write("<font
face=\"Verdana\" style=\"font-size: 12px;\"><font
color=\"#FF0000\"><b>Error:</b></font><br>" + errArray[0] +
"</font><br>");
}
finally
{
if (myReader != null) myReader.Close();
if (oConn.State == ConnectionState.Open) oConn.Close();
}
}
</script>
<html>
<head>
<title>Angebote</title>
</head>
<body>
<% ListObjects(); %>
<br>
<%= SQL %>
</body>
</html>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
| [aspdedotnet] als [email protected] subscribed
| http://www.aspgerman.com/archiv/aspdedotnet/ = Listenarchiv
| Sie k�nnen sich unter folgender URL an- und abmelden:
| http://www.aspgerman.com/aspgerman/listen/anmelden/aspdedotnet.asp