View Full Version : Insert Row to a table using ASP

08-18-2007, 02:56 PM
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.

08-18-2007, 10:41 PM
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 (http://www.connectionstrings.com) 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 (http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html).