Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 1.0/1.1
SQLDATASOURCE, problema con la query di delete
giovedì 12 gennaio 2006 - 17.29
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Friderich
Profilo
| Newbie
12
messaggi | Data Invio:
gio 12 gen 2006 - 17:29
La versione del mio framework è la 2.0
Io ho nella mia pagina asp, un gridview e un sql datasource, ho aggiunto alle colonne le la colonna per l'edit e d il delet di una stringa;
Questo è il codice che ho prodotto
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="Idutenti" HeaderText="Idutenti" SortExpression="Idutenti" />
<asp:BoundField DataField="Nome" HeaderText="Nome" SortExpression="Nome" />
<asp:BoundField DataField="Cognome" HeaderText="Cognome" SortExpression="Cognome" />
<asp:BoundField DataField="Cellulare" HeaderText="Cellulare" SortExpression="Cellulare" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AnagraficaConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:AnagraficaConnectionString1.ProviderName %>"
SelectCommand="SELECT [Idutenti], [Nome], [Cognome], [Cellulare] FROM [utenti]"
UpdateCommand="UPDATE [utenti] SET [Nome] = @Nome, [Cognome] = @Cognome, [Cellulare] = @Cellulare WHERE (Idutenti = @Idutenti)"
DeleteCommand="DELETE FROM [utenti] WHERE [Idutenti]=@Idutenti AND [Nome] = @Nome AND [Cognome] = @Cogome AND [Cellulare]= @Cellulare ">
<DeleteParameters>
<asp:Parameter Name="Idutenti" Type="string" />
<asp:Parameter Name="Nome" Type="string" />
<asp:Parameter Name="Cognome" Type="string" />
<asp:Parameter Name="Cellulare" Type="string" />
</DeleteParameters>
</asp:SqlDataSource>
L'update funziona mentre la delete mi da questo errore :
Must declare the scalar variable "@Idutenti".
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.SqlClient.SqlException: Must declare the scalar variable "@Idutenti".
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Non capisco cosa devo fare?!
GvnnRules
Profilo
| Senior Member
436
messaggi | Data Invio:
sab 14 gen 2006 - 11:34
Sei sicuro che Idutenti è stringa?
Tu hai dichiarato :
<asp:Parameter Name="Idutenti" Type="string" />
prova a dichiararlo del tipo del database (suppongo intero)
Peace
Gvnn
http://www.gvnn.it
http://www.sqlwebarchitect.org
http://blogs.dotnethell.it/gvnn/
novasolution.com
Profilo
| Newbie
4
messaggi | Data Invio:
gio 27 apr 2006 - 18:36
Anche se un pò in ritardo, è sempre meglio trovare le soluzioni ai problemi, ho riscontrato lo stesso problema postato nel seguente topic ed ho risolto così:
Nella Gridview, impostare nella proprietà DataKeyNames="" il nome del campo indice del database,
nel tuo caso "idutenti" per cui:
DataKeyNames="idutenti"
I paramentri possono anche non essere specificati le operazioni di Update e Delete funzionano lo stesso.
Ciao
novasolution.com - advanced web development
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !