salve ho il seguente file:
<%@ Page Language="VB" ValidateRequest="false" %>
<%@ Assembly Name="ADODB" %>
<%@ Import Namespace="ADODB" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
Private cn As New ADODB.Connection
Private Sub Inserisci(sender As Object, e As EventArgs)
' Eseguo un basilare controllo sui campi
If titolo.Text = "" Or descrizione.Text = "" Then
Messaggio.Text = "I campi sono entrambi obbligatori"
Exit Sub
End If
' Creo la stringa SQL di inserimento
Dim SQL As String = "INSERT INTO news " _
& "(data, titolo, descrizione)" _
& "VALUES" _
& "('" & FormatDateTime(Now(), 1) & "', " _
& "'" & Replace(titolo.Text, "'", "''") & "', " _
& "'" & Replace(descrizione.Text, "'", "''") & "')"
' Apro la connessione, eseguo la INSERT e chiudo la connessione
cn.Open("driver={Microsoft Access Driver (*.mdb)};dbq=" _
& Server.MapPath("database.mdb"))
cn.Execute(SQL)
cn.Close()
Messaggio.Text = "News inserita con successo"
End Sub
</script>
<html>
<head>
<title>Gestione delle News in ASP.NET</title>
</head>
<body>
<form id="Modulo" runat="server">
<table width="300" align="center" border="1">
<tr><td>Inserisci News</td></tr>
<tr>
<td>
Titolo
<asp:TextBox id="titolo" runat="server" MaxLength="50" Width="100%" />
Descrizione
<asp:TextBox id="descrizione" runat="server" MaxLength="50" Width="100%" />
<asp:Button ID="Button1" runat="server" Text="Inserisci" OnClick="Inserisci" />
</td>
</tr>
</table>
<p align="center"><asp:Label id="Messaggio" runat="server" /></p>
</form>
</body>
</html>
alla riga Private cn As New ADODB.Connection ottengo il seguente errore di compilazione:
"tipo ADODB.Connection non definito".
non so come risolvere l'errore...qualcuno così gentile che può aiutarmi?
tulipan

Rispondi quotando