scusate ho scritto questo codice:
codice:
Dim str as string = "Database=CURRICULUM;Server=localhost;user ID=user ;pwd=password "
Dim conn as new SqlConnection(str)
conn.open
Dim sql as string = "INSERT INTO [ANAGRAFICA] ([NOME], [COGNOME]) "
sql &= "VALUES = '" & lbNomeR.text & "',"
sql &= "'" & lbCognomeR.Text & "')"
Dim cmd as new sqlcommand(sql, conn)
cmd.ExecuteNonQuery
conn.close
che dovrebbe mettere in un db i due dati nome e cognome, ma dà errore:
Server Error in '/wcv' Application.
--------------------------------------------------------------------------------

Line 1: Incorrect syntax near '='.
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: Line 1: Incorrect syntax near '='.

Source Error:


Line 53: sql &= "'" & lbCognomeR.Text & "')"
Line 54: Dim cmd as new sqlcommand(sql, conn)
Line 55: cmd.ExecuteNonQuery
Line 56: conn.close
Line 57:


Source File: D:\Wcv\index.aspx Line: 55

Stack Trace:


[SqlException: Line 1: Incorrect syntax near '='.]
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +180
ASP.index_aspx.bangbang(Object sender, EventArgs e) in D:\Wcv\index.aspx:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573