Web Hosting Talk







View Full Version : ASP in Dreamweaver


slicktony
12-01-2002, 04:28 PM
I am developing a site using MS Access and Macromedia Dreamweaver MX.

The way I understand Access databases is the primary key is the index for the row and is unique to each one.

I would imagine that you would reference the primary key row and display the column (reference row 2 but display the third field in that row.

If I would like to display text from row 3 and field 2 how would I do that?

Or if it's SQL code what is the code?

Rich2k
12-01-2002, 07:42 PM
If I were you I'd get a book on ASP (this will detail database connections with SQL).

Basically all you need to do is create a database connection, the use a SQL statement something like SELECT * FROM table name

Then select the column you want

For example


'Create connection and recordset
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")

' Open connection to database
Conn.Open "databasename.mdb"

' SQL Statement to execute in this example we want record with id = 3
SQLStatement = "SELECT * FROM tablename WHERE id = 3"

' Execute the SQL statement
Set Rs = Conn.Execute(SQLStatement)

' Output the field called FIELDNAME from id = 3
Response.Write(Rs.Fields("FIELDNAME").value)

' Close recordset and connection to free up resources
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing


If you wanted to return multiple rows/results you'd need to add in a loop till end of recordset.