Sto usando il seguente codice per un esercizio...
Quando lo mando in esecuzione, mi viene fuori il seguente errore:codice:<%@Import Namespace="System.Data"%> <%@Import Namespace="System.Data.OleDb"%> <%@ Page Language="vb"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>Esercitazione</title> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> <script runat="server"> Sub Page_Load(obj as object, e as EventArgs) Dim conn as New oleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;" & _ "Data Source=c:\Dev\Data\banking.mdb") Dim ds as new DataSet("MyDataSet") Dim objCmd as new OleDbDataAdapter("SELECT * FROM tblUsers WHERE UserID < 10", Conn) objCmd.Fill(ds, "tblUsers") ds.Tables("tblUsers").Rows(2)(3) = "ASPVille" Dim dr as DataRow = ds.Tables("tblUsers").NewRow() dr(0) = "Greg" dr(1) = "Smith" dr(2) = "434 Maple Apt B" dr(3) = "Minneapolis" dr(4) = "MN" dr(5) = "12588" dr(6) = "5189876259" ds.Tables("tblUsers").Rows.Add(dr) objCmd.UpdateCommand = new OleDbCommand objCmd.UpdateCommand.CommandText = "Update tblUsers " & _ "SET City='ASPVille' WHERE UserID=3" objCmd.UpdateCommand.Connection = Conn objCmd.InsertCommand = new OleDbCommand objCmd.InsertCommand.CommandText="Insert INTO " & _ "tblUsers (Firstname, Lastname, Address, City, " & _ "State, ZIP, Phone) VALUES ( 'Greg', 'Smith', " & _ "'434 Maple Apt B', 'Minneapolis', 'MN', '12588', " & _ "'5189876259'" objCmd.InsertCommand.Connection = Conn End Sub </script> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> </form> </body> </HTML>
Errore server nell'applicazione '/DataGrid2'.
--------------------------------------------------------------------------------
Errore di sintassi nell'istruzione INSERT INTO.
Descrizione: Eccezione non gestita durante l'esecuzione della richiesta Web corrente. Per ulteriori informazioni sull'errore e sul suo punto di origine nel codice, vedere l'analisi dello stack.
Dettagli eccezione: System.Data.OleDb.OleDbException: Errore di sintassi nell'istruzione INSERT INTO.
Errore nel codice sorgente:
Riga 38: "'5189876259'"
Riga 39: objCmd.InsertCommand.Connection = Conn
Riga 40: objCmd.Update(ds, "tblUsers")
Riga 41: End Sub
Riga 42: </script>
A me sembra tutto corretto... non capisco!!!![]()
![]()
Qualcuno mi suggerisce qualcosa?

Rispondi quotando


