Newbie Q: Insert record in db

Discussion in 'ASP .Net' started by AlecL, Feb 26, 2007.

  1. AlecL

    AlecL Guest

    I am trying to insert a record in a control. All the webcontrols
    (i.e. textboxes, ddl, etc.) are also located on the control and the
    following code is executing the insert:

    Dim oOSQL As New System.Data.SqlClient.SqlCommand("INSERT INTO
    FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
    topic, comments) VALUES (sName, sEmail, sPhone, eMailTo, EnteredAs,
    sTopic, sComments)", Application("Public_DB_Conn"))
    oOSQL.Connection.Open()
    oOSQL.ExecuteNonQuery()
    oOSQL.Connection.Close()

    Although the code is not in a try catch block it is not generating any
    errors, but it does not enter any data in the db.

    Please help!!!!!!!!
     
    AlecL, Feb 26, 2007
    #1
    1. Advertising

  2. yes, but what is calling this procedure?
    maybe it really isn't calling it
     
    Mr. SweatyFinger, Feb 26, 2007
    #2
    1. Advertising

  3. AlecL

    Jared Guest

    On 26 Feb, 18:12, "AlecL" <> wrote:
    > I am trying to insert a record in a control. All the webcontrols
    > (i.e. textboxes, ddl, etc.) are also located on the control and the
    > following code is executing the insert:
    >
    > Dim oOSQL As New System.Data.SqlClient.SqlCommand("INSERT INTO
    > FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
    > topic, comments) VALUES (sName, sEmail, sPhone, eMailTo, EnteredAs,
    > sTopic, sComments)", Application("Public_DB_Conn"))
    > oOSQL.Connection.Open()
    > oOSQL.ExecuteNonQuery()
    > oOSQL.Connection.Close()
    >
    > Although the code is not in a try catch block it is not generating any
    > errors, but it does not enter any data in the db.
    >
    > Please help!!!!!!!!


    Hi

    Assuming that sName, sEmail, etc are controls, you need to concatenate
    their values into your string.

    e.g. VALUES(" + sName.Text + ", " + sEmail.Text + ", ....

    Cheers

    Jared
     
    Jared, Feb 26, 2007
    #3
  4. try
    dim sResult as string
    sResult = oOSQL.ExecuteNonQuery()
     
    Mr. SweatyFinger, Feb 26, 2007
    #4
  5. On Feb 26, 7:12 pm, "AlecL" <> wrote:
    > I am trying to insert a record in a control. All the webcontrols
    > (i.e. textboxes, ddl, etc.) are also located on the control and the
    > following code is executing the insert:
    >
    > Dim oOSQL As New System.Data.SqlClient.SqlCommand("INSERT INTO
    > FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
    > topic, comments) VALUES (sName, sEmail, sPhone, eMailTo, EnteredAs,
    > sTopic, sComments)", Application("Public_DB_Conn"))
    > oOSQL.Connection.Open()
    > oOSQL.ExecuteNonQuery()
    > oOSQL.Connection.Close()
    >
    > Although the code is not in a try catch block it is not generating any
    > errors, but it does not enter any data in the db.
    >
    > Please help!!!!!!!!


    at least

    "INSERT INTO
    FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
    topic, comments) VALUES ('" & sName & "', '" & sEmail & "....
     
    Alexey Smirnov, Feb 26, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    664
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  2. André
    Replies:
    0
    Views:
    3,780
    André
    Jun 25, 2006
  3. MRW
    Replies:
    0
    Views:
    398
  4. Frits van Soldt

    How to insert a new record in detailsview when there are no record

    Frits van Soldt, Nov 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    830
    Frits van Soldt
    Nov 17, 2005
  5. Guest
    Replies:
    1
    Views:
    285
    Alex G
    Jan 9, 2004
Loading...

Share This Page