Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder feras_wilson's Avatar
    Join Date
    Jul 2005
    Thanked 0 Times in 0 Posts

    Exclamation Insert Row to a table using ASP

    Hi all!
    I have a problem here. I need to know how to insert a row into a table. Can someone please give me the code please? i have searched in google but i am not understanding the code, so please give me the code that insert row into a table.

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Thanked 19 Times in 19 Posts
    This is done in a two step process:

    1) Create a connection to your database.

    2) Run the INSERT statement.

    Here's how you do it:
    Set Conn = Server.CreateConnection("ADODB.Connection")
    ' Connection via DSN
    Conn.Open "DSN=<your_dsn_name>"
    ' Connection via DSNLess (for Access)
    Conn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"
    ' Run the INSERT statement to input your values
    Conn.Execute "INSERT INTO your_table (column1, column2, column3) VALUES ('value1','value2','value3')"
    ' Close the connection
    ' Destroy the object
    Set Conn = Nothing
    Let us know if you have any other questions.

    If you need more connection strings, go to this website.

    If you need more help with SQL and INSERT statements, then you need to Google "SQL statements" or read Ch 12 of the MySQL manual on SQL Syntax, located here.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts