Hi! i ask you some help..I should build a simple INSERT FORM in a SQLExpress database..
but clicking ADD I have this error :
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: Incorrect syntax near '='.
Source Error:
Line 38: conDatabase.Open()
Line 39:
Line 40: cmdInsert.ExecuteNonQuery()
Line 41:
Line 42: conDatabase.Close() |
some solution?
the source code:
<%
@ Page Language="VB" Debug="true"%>
<%
@ Import Namespace="System.Data"%>
<%
@ Import Namespace="System.Data.SqlClient"%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
script runat="server">
Sub Button_clic(ByVal s As Object, ByVal e As EventArgs)
Dim conDatabase As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand
Dim myExecuteQuery As String
Dim myExecuteCmd As SqlCommand
conDatabase =
New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Inetpub\wwwroot\tesi\App_Data\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
strInsert =
"Insert pubblicazioni (Nome, Cognome, Titolo) Values = (@Nome, @Cognome, @Titolo) "
cmdInsert =
New SqlCommand(strInsert, conDatabase)
cmdInsert.Parameters.Add(
"@Nome", txtNome.Text)
cmdInsert.Parameters.Add(
"@Cognome", txtCognome.Text)
cmdInsert.Parameters.Add(
"@Titolo", txtTitolo.Text)
conDatabase.Open()
cmdInsert.ExecuteNonQuery()
conDatabase.Close()
Response.Redirect(
"success.html")
End Sub
</
script>
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head id="Head1" runat="server">
<title>iNSERIMENTO</title>
<LINK href="mauro.css" rel=stylesheet>
<
script type="text/javascript" language="javascript">
<!--
function
popopen(){
window.open(
"upload/upload.aspx","name"," toolbar=no,directories=no,menubar=no,width=300,height=300,top=100,left=150,resizable=no,scrollbars=yes");
}
// -->
</
script>
</
head>
<
body bgcolor="#DFE5F2" style="font-size: 12pt">
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" BackColor="#8080FF" BorderColor="Black"
ForeColor="Black" Height="29px" Text="FORM INSERIMENTO DOCUMENTO" Width="371px" Font-Bold="True" Font-Names="Verdana" Font-Size="14pt" Font-Underline="True"></asp:Label><br />
<br />
<br />
<B><span style="font-family: Verdana">NOME </span></B>
<asp:TextBox ID="txtNome" runat="server"></asp:TextBox>
<B><span style="font-family: Verdana">COGNOME </span></B>
<asp:TextBox ID="txtCognome" runat="server"></asp:TextBox><br />
<br />
<B><span style="font-family: Verdana">TITOLO </span></B>
<asp:TextBox ID="txtTitolo" runat="server"></asp:TextBox><br />
<br />
<a href="javascript:popopen()">CARICA DOCUMENTO</a><br/><br />
<asp:Button ID="Button1" runat="server" OnClick="Button_Clic" Text="ADD" Font-Bold="True" Font-Names="Verdana" Font-Size="12pt" Width="160px" /></div>
<br><br>
</form>
</
body>
</
html>