By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,459 Members | 2,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,459 IT Pros & Developers. It's quick & easy.

HELP! Retriving field names and properties from MS Access database using ASP

P: n/a
Hi everyone!

I have a really frustrating error and need help.
I’m trying to do a function that gets the properties and names
of the fields in a MS Access database using ASP. I haven’t
programmed in a while so I’m quite lost.

Once I have the my database structure I will insert the corresponding
fields from a web form but the database is huge and I want to be able
to change the database and form without changing the ASP code all the
time.

This is my function that is not working yet. I cant seem to connect
properly to the database...

Function InsertDataBase()
'# I connect with Conn earlier which works fine.

Dim Rec
Set Rec = Server.CreateObject("ADODB.Record")
Dim Fld

DBUrl = Server.MapPath("/_Data/Mydb.mdb") '#
"http://myserver/_Data/Mydb.mdb"

'# Get the database structure
Dim ConnDir
Set ConnDir = Server.CreateObject("ADODB.Connection")
Response.write Server.MapPath("/_Data/")
'ConnDir.Provider = "ExOLEDB.DataSource" '# This row gives the error:
Provider cannot be found. It may not be properly installed.
ConnDir.Open "http://myserver/_Data" '# This row (_Data is a
directory) gives the error: [Microsoft][ODBC Driver Manager] Data
source name not found and no default driver specified
Rec.Open "http://myserver/_Data/Mydb.mdb", ConnDir

'Rec.Open DBUrl, Conn, adModeReadWrite

'# Validate each field according to the structure and create SQL
statement
strSQL = "INSERT INTO Andres ( "
strVALUES = ""
For Each Fld in Rec.Fields
Response.write "<BR>Fieldsssss: " & Fld.Properties(.Name) & " " &
Fld.Properties(.Type) & " " & Fld.Properties(.Size)
strSQL = strSQL & "[" & Fld.Properties(.Name) & "], "

strVALUES = strVALUES & "'" & validate(
Reqsafe(Fld.Properties(.Name)), Fld.Properties(.Type),
Fld.Properties(.Size) ) & "', "

Next
strSQL = Left( strSQL, len(strSQL)-2) ' Removes the last ", "
strVALUES = Left( strVALUES, len(strSQL)-2) ' Removes the last ", "
strSQL = strSQL & " ) VALUES ( " & strVALUES
Rec.Close

'# Execute SQL statement
set rs = conn.execute(strSQL)

End Function

I would really appreciate all help or suggestions I can get!!! Thanks
in advance!

Patricio
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.