Di seguito è riportata la funzione che dovrebbe inserire il mio record nel database
codice:<%@ import Namespace="System.Security.Principal" %> <%@ import Namespace="System.Data.OleDb" %> <%@ import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb"%> <%@ Page Language="VB" Debug="True" validateRequest="false" %> <HTML> <HEAD> <title>Bijou - Login errato</title> <script runat="server"> Sub DoReg(ByVal o As Object, ByVal e As EventArgs) Dim strConn As String Dim objConn As OleDbConnection Dim strsql As String Dim objCommand As OleDbCommand strConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("data/bijou.mdb") objConn = New OleDbConnection(strConn) objConn.Open() strsql = "INSERT INTO Utenti ([id],[password],[role],[nome],[cognome],[indirizzo],[civico],[telefono],[cellulare],[e_mail]) VALUES ('" & txtid.Value & "','" & txtpwd.Value & "','Utente','" & txtnome.Value & "','" & txtnome.Value & "','" & txtcognome.Value & "','" & txtindirizzo.Value & "','" & txtcivico.Value & "','" & txttelefono.Value & "','" & txtcell.Value & "','" & txtmail.Value & "',);" objCommand = New OleDbCommand(strsql, objConn) objCommand.ExecuteNonQuery() 'objCommand.ExecuteReader(CommandBehavior.CloseConnection) objConn.Close() End Sub </script>
mentre questo è il codice del form che richiama la funzione di inserimento
codice:<form method="post" action="registrazione.aspx" runat=server> <table cellSpacing="0" cellPadding="0" align="center" border="0"> <tr> <td class="testo" id="lblid" align="left" runat="server">Nome Utente: </td> <td width="25"></td> <td align="right"><input class="campo" id="txtid" type="text" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblpwd" align="left" runat="server">Password: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtpwd" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblnome" align="left" runat="server">Nome: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtnome" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblcognome" align="left" runat="server">Cognome: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtcognome" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblindirizzo" align="left" runat="server">Indirizzo: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtindirizzo" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblcivico" align="left" runat="server">n°civico: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtcivico" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lbltelefono" align="left" runat="server">Telefono: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txttelefono" type="text" name="Text2" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblcell" align="left" runat="server">Cellulare: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtcell" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" id="lblmail" align="left" runat="server">E-Mail: </td> <td width="25"></td> <td align="right" width="82"><input class="campo" id="txtmail" type="text" name="Text1" runat="server" onserverchange="utente_ServerChange"> </td> </tr> <tr> <td class="testo" align="left" colSpan="3"> <div style="margin:10,0,0,0"> Invia i datiCancella</P> </div> </td> </tr> </table> </form>
ho fatto tutte le prove possibile ma l'erroe che è visualizzato p il seguente
ho provato a togliere le quadrema mi dice che sbaglio la insert intoIl numero dei valori nella query non corrisponde a quello dei campi di destinazione.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Il numero dei valori nella query non corrisponde a quello dei campi di destinazione.
Source Error:
Line 23: strsql = "INSERT INTO [Utenti] ([id],[password],[role],[nome],[cognome],[indirizzo],[civico],[telefono],[cellulare],[e_mail]) VALUES ('" & txtid.Value & "','" & txtpwd.Value & "','Utente','" & txtnome.Value & "','" & txtnome.Value & "','" & txtcognome.Value & "','" & txtindirizzo.Value & "','" & txtcivico.Value & "','" & txttelefono.Value & "','" & txtcell.Value & "','" & txtmail.Value & "',);"
Line 24: objCommand = New OleDbCommand(strsql, objConn)
Line 25: objCommand.ExecuteNonQuery()
Line 26: 'objCommand.ExecuteReader(CommandBehavior.CloseCon nection)
Line 27: objConn.Close()
Source File: C:\Inetpub\wwwroot\bijouremake\registrazione.aspx Line: 25
Stack Trace:
[OleDbException (0x80040e14): Il numero dei valori nella query non corrisponde a quello dei campi di destinazione.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +56
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +105
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +89
ASP.registrazione_aspx.DoReg(Object o, EventArgs e) in C:\Inetpub\wwwroot\bijouremake\registrazione.aspx: 25
System.Web.UI.HtmlControls.HtmlAnchor.OnServerClic k(EventArgs e) +75
System.Web.UI.HtmlControls.HtmlAnchor.RaisePostBac kEvent(String eventArgument) +96
System.Web.UI.HtmlControls.HtmlAnchor.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +172
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4924
ma dove???? :master: