' http://forums.asp.net/t/1764216.aspx?Connect+to+accdb+Database+with+WebMatrix @using System.Data @* My page worked just fine without this using statement, but I'll throw it in just in case.*@ @using System.Data.OleDb @* Be sure to include this using statement for the OLE DB .NET Data Provider namespace. *@ @{ Page.Title = "Database Test Page"; } @{ // Create connection object for Microsoft Access OLE DB Provider. // Again, notice the @ sign prefacing the string literal so that the slashes // in the path name aren't interpreted as escape characters. var thisConnection = new OleDbConnection(@"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\Administrator\Documents\My Web Sites\Sito vuoto\App_Data\CONCADORO.mdb"); // Open Connection object thisConnection.Open(); // Create SQL command object on this connection var thisCommand = thisConnection.CreateCommand(); // Initialize SQL Select command to retrieve desired data thisCommand.CommandText = "SELECT * FROM aNAGRAFICA"; // Create a DataReader object based on previously defined command object OleDbDataReader thisReader = thisCommand.ExecuteReader(); <style type="text/css"> .table { margin: 20px; border-collapse: separate; width: 800px; } .grid th, .table td { border: 2px solid #C0C0C0; padding: 5px; } .head { background-color: #E8E8E8; font-weight: bold; color: #FFF; } .alt { background-color: #E8E8E8; color: #000; } </style> <table border="1" style="alignment-adjust: central; " class="table" > <!-- Nome colonne --> <tr><td> Cosa:</td><td>Nominativo:</td><td>Palazzina:</td><td>Scala:</td><td>Interno:</td><td>Indirizzo:</td><td>Recapito:</td></tr> @* Read() Advances the OleDbDataReader to the next record *@ @while(thisReader.Read()) { <tr> <td> <a href="~/cshtml/DeleteMovie?id=@thisReader["ID"]">Delete</a></td> <td>@thisReader["nOMINATIVO"]</td> <td>@thisReader["PALAZZINA"]</td> <td>@thisReader["SCALA"]</td> <td>@thisReader["interno"]</td> <td>@thisReader["Indirizzo"]</td> <td>@thisReader["Recapito"]</td> </tr> } </table> } |