April 8, 2003 at 3:33 pm
I've isolated a general protection fault to the following code:
Dim sqlCol As Column
Dim sqlView as View
Set sqlView = objSQL.Databases(1).views(1)
For Each sqlCol In sqlView.ListColumns
... do something
Next sqlCol
this code works fine but when closing the application - it GPF's. Eliminating this code eliminates the GPF.
Is there any other syntax to get the Columns collection of a View object in SQLDMO?
TIA
Brian Lockwood
LockwoodTech Software
Brian Lockwood
President
ApexSQL - SQL Developer Essentials
April 8, 2003 at 4:01 pm
how about this for an alternative ...
Dim sqlView as View
Dim qry As SQLObjectList
Set sqlView = objSQL.Databases(1).views(1)
Set qry = sqlView.ListColumns
the only problem is what is the syntax to iterate though the qry object
qry.item(????) item method expects something other than a number but I can't find named params.
TIA
Brian Lockwood
LockwoodTech Software
Brian Lockwood
President
ApexSQL - SQL Developer Essentials
April 8, 2003 at 4:17 pm
I just put compiled and ran your code, no GPF. I'll have to work on your other idea more.
Dim oserver As SQLDMO.SQLServer
'create standard server object first
Set oserver = New SQLDMO.SQLServer
With oserver
.LoginSecure = True
.Connect "eg\one"
End With
Dim sqlCol As Column
Dim sqlView As View
Set sqlView = oserver.Databases("Northwind").Views(1)
For Each sqlCol In sqlView.ListColumns
Debug.Print sqlCol.Name
Next sqlCol
oserver.DisConnect
Set oserver = Nothing
Andy
April 8, 2003 at 6:54 pm
no - this code does not directly cause a GPF. If that were the case I could have isolated it very easily. It indirectly makes the app. unstable and on exit - BOOM.
In fact - if I run this code at all during the instance of my application - all is fine. It works like a charm.
BUT ... when you close the application you get a General Protection Fault. Now this isn't a show stopper but the GPFs are damn annoying.
How could I tell that this line is the culprit? I had to isolate it by process of elimination - running these lines will enable me to dupe the prob. everytime. Eliminating it will fix it.
So my only goal now is a workaround using my second method but SQLDMO documentation sucks so much that I can't find the means to iterate through the qry object.
Next step is to just go back to system tables.
Brian Lockwood
LockwoodTech Software
Brian Lockwood
President
ApexSQL - SQL Developer Essentials
April 8, 2003 at 7:20 pm
Its still a collection of column objects. Code below works. Dont know if it will help you. Tried using the "2" objects to see if that makes a difference, if that is an option?
Dim oList As SQLDMO.SQLObjectList
Dim oCol As SQLDMO.Column
Set sqlView = oserver.Databases("Northwind").Views(1)
Set oList = sqlView.ListColumns
For Each oCol In oList
Debug.Print oCol.Name
Next
Andy
April 8, 2003 at 7:41 pm
i tried a few ways but same behavior.
(to clarify - you have to compile the app. first - behavior isn't exposed during VB runtime)
there is an item method to the qry object in my sample analagous to the object you created.
but perhaps the only way you can get at it is by looping the columns through it.
anyway I've got back to sp_columns for views. this listcolumns method really made my app. unstable. too bad because i much prefer DMO in general to direct sql calls to system tables.
thx much for the help and the next time you see a GPF in my apps. ... blame MSFT 🙂
Brian Lockwood
LockwoodTech Software
Brian Lockwood
President
ApexSQL - SQL Developer Essentials
April 9, 2003 at 5:13 am
I tried to iterate a couple different ways, column object was only one that worked. Weird. As far as the GPF, you're running VB6 SP5? I can see where going back to the system calls makes sense.
Andy
April 9, 2003 at 8:29 am
thx much for the help. i already pulled this code and went back to system tables.
i appreciate the help though.
Brian Lockwood
LockwoodTech Software
Brian Lockwood
President
ApexSQL - SQL Developer Essentials
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply