473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

ADOX... Unknown runtime error

Hi,

I keep getting an Unknown runtime error on line 3 below:

1 If oField.Type <> 136 Then 'adChapter
2 If Right(oField.name, 3) = "_id" Then
3 For Each oKey In oTable.Keys
4 If oKey.Type = 2 Then 'adKeyForeign
5 Set oCol = oKey.Columns(0)

Something wrong with this??

Thanks,
Ivan
Jul 21 '05 #1
7 2813
What kind of database? What is the rest of the code?

Ray at home

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Hi,

I keep getting an Unknown runtime error on line 3 below:

1 If oField.Type <> 136 Then 'adChapter
2 If Right(oField.name, 3) = "_id" Then
3 For Each oKey In oTable.Keys
4 If oKey.Type = 2 Then 'adKeyForeign
5 Set oCol = oKey.Columns(0)

Something wrong with this??

Thanks,
Ivan

Jul 21 '05 #2
Access 2000 format. here's the whole snippet:

'Check for foreign keys
For Each oField In oSource.fields
If oField.Type <> 136 Then 'adChapter
If Right(oField.name, 3) = "_id" Then
For Each oKey In oTable.Keys
If oKey.Type = 2 Then 'adKeyForeign
Set oCol = oKey.Columns(0)
If (oCol.name = oField.name) And (oField.Value > 0) Then
On Error Resume Next
lFID = 0
lFID = Session.Contents(oKey.RelatedTable & "." & oField.Value)
If (Err.Number <> 0) or (lFID = 0) Then
lFID = oField.Value
Err.Clear
End If
On Error GoTo 0

If lFID <> oField.Value Then
oField.Value = lFID
End If

Exit For
End If
End If
Next
End If
End If
Next

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:uY**************@TK2MSFTNGP12.phx.gbl...
What kind of database? What is the rest of the code?

Ray at home

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Hi,

I keep getting an Unknown runtime error on line 3 below:

1 If oField.Type <> 136 Then 'adChapter
2 If Right(oField.name, 3) = "_id" Then
3 For Each oKey In oTable.Keys
4 If oKey.Type = 2 Then 'adKeyForeign
5 Set oCol = oKey.Columns(0)

Something wrong with this??

Thanks,
Ivan


Jul 21 '05 #3
My guess is that the problem is not with your code. Perhaps reinstalling
MDAC would help? Are you using an OLEDB connection?

This code, run on a W2K Server, works fine. I commented out all the stuff
after line 3, the one where you got an error, and all went well.
<%
Dim oADO, oADOX, oTable
Set oADO = CreateObject("ADODB.Connection")
Set oADOX = CreateObject("ADOX.Catalog")
oADO.Open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Usw\test.mdb;"
oADOX.ActiveConnection = oADO

For Each oTable In oADOX.Tables
'For Each oField In oSource.fields
' If oField.Type <> 136 Then 'adChapter
' If Right(oField.name, 3) = "_id" Then
For Each oKey In oTable.Keys
Response.Write oKey.Type

'If oKey.Type = 2 Then 'adKeyForeign
' Set oCol = oKey.Columns(0)
' If (oCol.name = oField.name) And (oField.Value > 0) Then
' On Error Resume Next
' lFID = 0
' lFID = Session.Contents(oKey.RelatedTable & "." &
oField.Value)
' If (Err.Number <> 0) or (lFID = 0) Then
' lFID = oField.Value
' Err.Clear
' End If
' On Error GoTo 0
' If lFID <> oField.Value Then
' oField.Value = lFID
' End If
' Exit For
' End If
'End If
Next
' End If
' End If
'Next

Next

Set oADOX = Nothing
oADO.Close : Set oADOX = Nothing

%>
Also check out the Access alternative option here.
http://www.aspfaq.com/show.asp?id=2520

Ray at work
"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
Access 2000 format. here's the whole snippet:

'Check for foreign keys
For Each oField In oSource.fields
If oField.Type <> 136 Then 'adChapter
If Right(oField.name, 3) = "_id" Then
For Each oKey In oTable.Keys
If oKey.Type = 2 Then 'adKeyForeign
Set oCol = oKey.Columns(0)
If (oCol.name = oField.name) And (oField.Value > 0) Then
On Error Resume Next
lFID = 0
lFID = Session.Contents(oKey.RelatedTable & "." & oField.Value)
If (Err.Number <> 0) or (lFID = 0) Then
lFID = oField.Value
Err.Clear
End If
On Error GoTo 0

If lFID <> oField.Value Then
oField.Value = lFID
End If

Exit For
End If
End If
Next
End If
End If
Next

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:uY**************@TK2MSFTNGP12.phx.gbl...
What kind of database? What is the rest of the code?

Ray at home

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Hi,

I keep getting an Unknown runtime error on line 3 below:

1 If oField.Type <> 136 Then 'adChapter
2 If Right(oField.name, 3) = "_id" Then
3 For Each oKey In oTable.Keys
4 If oKey.Type = 2 Then 'adKeyForeign
5 Set oCol = oKey.Columns(0)

Something wrong with this??

Thanks,
Ivan



Jul 21 '05 #4
I'm suspecting it has to do with the connection. Unfortunately I just can't
reinstall MDAC... the website is hosted at an ISP :)

I returned the connection string and it was really strange. The provider was
MSDASQL, a DBQ property instead of Data Source, and other ODBC properties
that I never used... I configured the DSN using the site's control panel.

The code is definitely good because the same code is used locally and works
100%. I'll be changing the connection string and hope for the best!!

Ivan

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:ut**************@TK2MSFTNGP15.phx.gbl...
My guess is that the problem is not with your code. Perhaps reinstalling
MDAC would help? Are you using an OLEDB connection?

This code, run on a W2K Server, works fine. I commented out all the stuff
after line 3, the one where you got an error, and all went well.
<%
Dim oADO, oADOX, oTable
Set oADO = CreateObject("ADODB.Connection")
Set oADOX = CreateObject("ADOX.Catalog")
oADO.Open"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Usw\test.mdb;"
oADOX.ActiveConnection = oADO

For Each oTable In oADOX.Tables
'For Each oField In oSource.fields
' If oField.Type <> 136 Then 'adChapter
' If Right(oField.name, 3) = "_id" Then
For Each oKey In oTable.Keys
Response.Write oKey.Type

'If oKey.Type = 2 Then 'adKeyForeign
' Set oCol = oKey.Columns(0)
' If (oCol.name = oField.name) And (oField.Value > 0)
Then
' On Error Resume Next
' lFID = 0
' lFID = Session.Contents(oKey.RelatedTable & "." &
oField.Value)
' If (Err.Number <> 0) or (lFID = 0) Then
' lFID = oField.Value
' Err.Clear
' End If
' On Error GoTo 0
' If lFID <> oField.Value Then
' oField.Value = lFID
' End If
' Exit For
' End If
'End If
Next
' End If
' End If
'Next

Next

Set oADOX = Nothing
oADO.Close : Set oADOX = Nothing

%>
Also check out the Access alternative option here.
http://www.aspfaq.com/show.asp?id=2520

Ray at work
"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
Access 2000 format. here's the whole snippet:

'Check for foreign keys
For Each oField In oSource.fields
If oField.Type <> 136 Then 'adChapter
If Right(oField.name, 3) = "_id" Then
For Each oKey In oTable.Keys
If oKey.Type = 2 Then 'adKeyForeign
Set oCol = oKey.Columns(0)
If (oCol.name = oField.name) And (oField.Value > 0) Then
On Error Resume Next
lFID = 0
lFID = Session.Contents(oKey.RelatedTable & "." & oField.Value)
If (Err.Number <> 0) or (lFID = 0) Then
lFID = oField.Value
Err.Clear
End If
On Error GoTo 0

If lFID <> oField.Value Then
oField.Value = lFID
End If

Exit For
End If
End If
Next
End If
End If
Next

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:uY**************@TK2MSFTNGP12.phx.gbl...
What kind of database? What is the rest of the code?

Ray at home

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Hi,

I keep getting an Unknown runtime error on line 3 below:

1 If oField.Type <> 136 Then 'adChapter
2 If Right(oField.name, 3) = "_id" Then
3 For Each oKey In oTable.Keys
4 If oKey.Type = 2 Then 'adKeyForeign
5 Set oCol = oKey.Columns(0)

Something wrong with this??

Thanks,
Ivan



Jul 21 '05 #5
Ah, yes, instead of using the DSN setup through that control panel, can you
just use a "good ole" OLEDB connection string? Assuming that your Access
databases are stored in a directory, /databases, on your site:
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/databases/yourfile.mdb")
oADO.OPen sConnectionSTring

Ray at work

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I'm suspecting it has to do with the connection. Unfortunately I just
can't reinstall MDAC... the website is hosted at an ISP :)

I returned the connection string and it was really strange. The provider
was MSDASQL, a DBQ property instead of Data Source, and other ODBC
properties that I never used... I configured the DSN using the site's
control panel.

The code is definitely good because the same code is used locally and
works 100%. I'll be changing the connection string and hope for the best!!

Ivan

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:ut**************@TK2MSFTNGP15.phx.gbl...
My guess is that the problem is not with your code. Perhaps re

Jul 21 '05 #6
It works now!!

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:Op**************@TK2MSFTNGP09.phx.gbl...
Ah, yes, instead of using the DSN setup through that control panel, can
you just use a "good ole" OLEDB connection string? Assuming that your
Access databases are stored in a directory, /databases, on your site:
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/databases/yourfile.mdb")
oADO.OPen sConnectionSTring

Ray at work

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I'm suspecting it has to do with the connection. Unfortunately I just
can't reinstall MDAC... the website is hosted at an ISP :)

I returned the connection string and it was really strange. The provider
was MSDASQL, a DBQ property instead of Data Source, and other ODBC
properties that I never used... I configured the DSN using the site's
control panel.

The code is definitely good because the same code is used locally and
works 100%. I'll be changing the connection string and hope for the
best!!

Ivan

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> schrieb im
Newsbeitrag news:ut**************@TK2MSFTNGP15.phx.gbl...
My guess is that the problem is not with your code. Perhaps re


Jul 21 '05 #7
Ein Malteser in Deutschland?

"Ivan Debono" <iv******@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
Hi,

I keep getting an Unknown runtime error on line 3 below:

1 If oField.Type <> 136 Then 'adChapter
2 If Right(oField.name, 3) = "_id" Then
3 For Each oKey In oTable.Keys
4 If oKey.Type = 2 Then 'adKeyForeign
5 Set oCol = oKey.Columns(0)

Something wrong with this??

Thanks,
Ivan

Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: KemperR | last post by:
Hello Experts outhere, may be someone can tell me whats going wrong with my ADOX trial. I have an Access 2002 database with some tables and queries (views) The code listed below works well up...
44
by: Greg Strong | last post by:
Hello All, Is it better to create a query in DAO where a report has 4 sub-reports each of whose record source is a query created at runtime and everything is in 1 MDB file? From what I've...
5
by: Lars-Erik Aabech | last post by:
Hi! Guess it's my day again.. Tried to deploy a test release of a new asp.net web today, and got a terrible error. The web is running swell on three development computers, but when it's copied...
2
by: Randy | last post by:
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConnection link "Arguments are of the wrong type,...
2
by: Tim Frawley | last post by:
I am attempting to change the ODBC Link Provider String in an Access database linked to an Oracle server using ADOX in VB.NET. I created some code using the example from post:...
3
by: gaffar | last post by:
Sir, Using ADOX I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the...
3
by: Miro | last post by:
Something weird I have run into when trying to add a boolean field to an Access table by code. -Just wondering if anyone else has run into this. ( vb.net 2005 express ) If I add any other...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
7
by: The Mad Ape | last post by:
When I use the code below to create an mdb (access database) I am unable to release it and the locking file remains persistent. For my app this is bad if the user tries to delete the mdb later on....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.