Sto cercando di fare un insert nel db, non mi da nessun errore, anzi mi dice "Database now updated", ma di inserimento nel db nn vi è traccia...
Mi aiutate a risolvere? Grazie
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Oledb" %>
<script runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
End Sub
Private ReadOnly Property StringaConnessione() As String
Get
Return "Provider=Microsoft.Jet.OLEDB.4.0;"& "Data Source=" & Server.MapPath("collana.mdb")&""
End Get
End Property
Sub InserisciDati(Source as Object, E as EventArgs)
Dim cn
Dim str
Dim cmd
Dim icount As Integer
cn = New OleDbConnection(StringaConnessione)
Dim titolo = Request.Form("TextBox1")
Dim descrizione = Request.Form("TextBox2")
Try
cn.Open()
str = "insert into libri"
str = str &"titolo,"
str = str &"descrizione,"
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery()
' Response.Write(str)
Catch
cn.Close()
End Try
Label1.Text = "Database now updated"
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Inserimento dati</title>
</head>
<body>
<div id="div1" >
<form action="registrazione.aspx" method="post" name="collana" id="collana" runat="server">
<table width="731" border="0" align="center">
<tr>
<td colspan="4" align="center" valign="middle">Iserimento dati</td>
</tr>
<tr>
<td width="168" align="center" valign="middle">Titolo</td>
<td colspan="3" align="left" valign="middle"><asp:TextBox ID="TextBox1" TextMode="SingleLine" runat="server" /><asp:RequiredFieldValidator ControlToValidate="TextBox1" ID="txtTextBox1" runat="server" Text="*Richesto" />
</td>
</tr>
<tr>
<td align="center" valign="middle">Descrizione</td>
<td colspan="3" align="left" valign="middle"><asp:TextBox ID="TextBox2" TextMode="SingleLine" runat="server" /><asp:RequiredFieldValidator ControlToValidate="TextBox2" ID="txtTextBox2" runat="server" Text="*Richesto" />
</td>
</tr>
<tr>
<td align="center" valign="middle">Inserisci</td>
<td colspan="3" align="left" valign="middle"><asp:Button ID="Button1" Text="Invia" runat="server" onClick="InserisciDati"/></td>
</tr>
</table>
</form>
<div id="div2" align="center"></div>
<asp:Label ID="label1" runat="server"></asp:Label>
</body>
</html>