HELP - insert record SQLExpress database

Last post 02-27-2007 3:49 AM by thirdeyed. 2 replies.

Sort Posts:

  • HELP - insert record SQLExpress database

    02-26-2007, 9:38 AM
    • Loading...
    • thirdeyed
    • Joined on 02-26-2007, 9:25 AM
    • Posts 4

    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>

    &nbsp;<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&nbsp; </span></B>

    <asp:TextBox ID="txtNome" runat="server"></asp:TextBox>

    &nbsp; &nbsp; <B><span style="font-family: Verdana">COGNOME&nbsp; </span></B>

    <asp:TextBox ID="txtCognome" runat="server"></asp:TextBox><br />

    <br />

    <B><span style="font-family: Verdana">TITOLO&nbsp; </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>
  • Re: HELP - insert record SQLExpress database

    02-26-2007, 1:21 PM
    Answer
    • Loading...
    • ndinakar
    • Joined on 05-05-2003, 4:57 PM
    • Redmond, WA
    • Posts 6,837
    • Moderator
      TrustedFriends-MVPs
    Remove the "=" sign in the INSERT statement.
    ***********************
    Dinakar Nethi
    Life is short. Enjoy it.
    ***********************
  • Re: HELP - insert record SQLExpress database

    02-27-2007, 3:49 AM
    • Loading...
    • thirdeyed
    • Joined on 02-26-2007, 9:25 AM
    • Posts 4

    ndinakar:
    Remove the "=" sign in the INSERT statement.

     

    damn!ehehehe ; ) thanks you.....

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter