Solved

create access db and fill'er up - HOW? (asp -vbscript-adox)

Posted on 2004-08-05
2
760 Views
Last Modified: 2008-01-09
I'm tearing my hair! Why the bloody h... wont this work???
I'm creating an access database file in ASP and ADOX.
This works great, but no records get put in it. no errors or anything just plain empty.
this is my code:

<!--#include file="../../../../../program files/common files/System/ado/adovbs.inc"-->
<%
Const Jet10 = 1
Const Jet11 = 2
Const Jet20 = 3
Const Jet3x = 4
Const Jet4x = 5
dim dbName, tableName, dbPath, rs_q, sql, fso
dbName = "C:\inetpub\wwwroot\survey\avmedia\Library\johan.mdb"
tableName = "test"
dbPath="../Library/"&right(dbName,(len(dbName)-42))
set fso=server.CreateObject("Scripting.FileSystemObject")
Function dbReady(dbName)
   dbReady = fso.FileExists(dbName)
End Function
Sub CreateNewMDB(FileName, Format, tableName, tableId)
  Dim Catalog
  Set Catalog = CreateObject("ADOX.Catalog")
  Catalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=" & Format & ";Data Source=" & FileName
      Dim TheTable
      Set TheTable = Server.CreateObject("ADOX.Table")
      TheTable.Name = tableName
      TheTable.Columns.Append "id", adInteger
      TheTable.Columns.Append "namn", adLongVarWChar, 255
      TheTable.Columns.Append "tel", adLongVarWChar, 255
      TheTable.Keys.Append "PK_id", 1, "id"
      Catalog.Tables.Append TheTable
      set conn2 = server.CreateObject("ADODB.connection")
      conn2.open(catalog.activeConnection)
      conn2.execute("INSERT INTO test VALUES(123,'asdfsafd','safsfdsaf')")
      Set TheTable = Nothing
      Set Catalog = Nothing
End Sub
if dbReady(dbName) then fso.DeleteFile(dbName)
CreateNewMDB dbName, Jet4x, tableName, request.QueryString("survey_id")
do
      i=i+1
      if dbReady(dbName) then exit do
      if i >=10000 then
            response.Write("error :(")
            exit do
      end if
loop
response.Redirect(dbPath)
 %>

please help
0
Comment
Question by:kojoman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 125 total points
ID: 11726839
try this - change:

  set conn2 = server.CreateObject("ADODB.connection")
  conn2.open(catalog.activeConnection)

to:

set conn2 = catalog.activeConnection
conn2.execute("INSERT INTO test VALUES(123,'asdfsafd','safsfdsaf')")

since catalog.ActiveConnection is a VALID connection object, you simply use it, rather than creating a NEW connection.

AW
0
 

Author Comment

by:kojoman
ID: 11733740
Thanks man!
I had it like that from the beginning, but then there were some other stuff that didn't work and in the intense debugging I changed it to see if that solved the current problem, which didn't get affected at all.
It works great now. Thanks a lot.
-johan
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question