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

ADOX... Unknown runtime error

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.