|
-
Jun 10th, 2003, 11:55 AM
#1
Thread Starter
New Member
"User defined type not defined" error
Hi,
I am gettin the "User defined type not defined" error at this point in the code
Private Function AppendFields(CurMap As MapObjects2.Map, CurLegend As MO2legend.legend, NewRecordset As ADODB.Recordset, colParameters As Collection)
I thought its cos i am not providing reference for adodb, even after addin the reference ,error still persists. does collection object need any reference? Could you please tell me what might be going wrong?
Thanks
Karunya
-
Jun 10th, 2003, 12:11 PM
#2
Mak sure you've added whatever references you need to use MapObjects2 and MO2legend.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 10th, 2003, 12:49 PM
#3
Thread Starter
New Member
Thanks for the suggestion.The error still persists.can u suggest somethin else?
thanks
karunya
-
Jun 10th, 2003, 03:21 PM
#4
That may not be the actual line of error. Look in your project references and components and make sure nothing is marked "MISSING".
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jun 10th, 2003, 07:28 PM
#5
PowerPoster
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jun 10th, 2003, 11:21 PM
#6
Thread Starter
New Member
Hi,
This is the code. When the error appears, the "Public Sub AppendFields(CurMap As MapObjects2.Map, CurLegend As MO2legend.legend, NewRecordset As ADODB.Recordset, colParameters As Collection)" is highlighted. Let me know guys if u can make out somethin from this.It will be of great help to me
Thanks
karunya
Public Sub AppendFields(CurMap As MapObjects2.Map, CurLegend As MO2legend.legend, NewRecordset As ADODB.Recordset, colParameters As Collection)
Dim lyr As MapObjects2.MapLayer
Dim tDesc As MapObjects2.TableDesc
Dim dc As MapObjects2.DataConnection, cn As ADODB.Connection
Dim str As String, lyrpath As String, lyrname As String
'Initialize the active layer
Set lyr = CurMap.Layers(CurLegend.getActiveLayer)
'Verify the field name, if it already exist in the shapefile table
Dim VerRes As MapObjects2.Recordset
Set VerRes = lyr.Records
Dim x As Integer, Y As Integer
For Y = 1 To colParameters.Count
For x = 0 To VerRes.TableDesc.FieldCount - 1
If colParameters.Item(Y) = VerRes.TableDesc.FieldName(x) Then
MsgBox "The field is already exist in the target shapefile, please specify another unique name", vbOKOnly, "Watshman -- Information"
Exit Sub
End If
Next x
Next Y
Set VerRes = Nothing
frmMeasurement.MousePointer = 11
'Take away the string "[Shapefile]" & filename, the reason has them is they can be easily used
'for address matching
lyrpath = Left(lyr.Tag, (Len(lyr.Tag) - Len(lyr.Name) - 1))
lyrpath = Right(lyrpath, (Len(lyrpath) - 11))
lyrname = lyr.Name
CurMap.Layers.Remove (CurLegend.getActiveLayer)
Set dc = New MapObjects2.DataConnection
Set tDesc = New MapObjects2.TableDesc
dc.Database = lyrpath
Dim tempFileName As String
tempFileName = "Temp" & Int((1000 * Rnd) + 1) 'Rondom append a number to "temp" string
Set lyr.GeoDataset = dc.AddGeoDataset(tempFileName, moShapeTypePoint, tDesc)
CurMap.Refresh
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft Visual Foxpro Driver};SourceType=DBF;SourceDB=" & lyrpath
'Add columns according to the number of parameters in the ResFinal recordset
Dim i As Integer
Dim strTemp As String 'The temp string for each parameter name for each added column
NewRecordset.MoveFirst
cn.BeginTrans
For i = 1 To colParameters.Count
strTemp = VerifyName(colParameters.Item(i)) 'Validate string
strTemp = Left(strTemp, 8)
str = "ALTER TABLE " & lyrname & " ADD COLUMN " & strTemp & " NUMERIC(16,3)"
cn.Execute (str)
NewRecordset.MoveNext
Next i
cn.CommitTrans
'Update field values
Dim m As Integer, n As Integer
strTemp = "" 'Reset data manipulation SQL string
str = ""
cn.BeginTrans
NewRecordset.MoveFirst
'Update each field(Parameter) by referencing the current record
For m = 1 To NewRecordset.RecordCount
strTemp = VerifyName(colParameters.Item(i)) 'Validate string
strTemp = Left(strTemp, 8)
str = "UPDATE " & lyrname & " SET " & strTemp & " = " & NewRecordset.Fields("AvgOfvalue").Value & " WHERE Feature_ID = " & CLng(NewRecordset.Fields("FeatureID").Value)
cn.Execute (str)
If Not NewRecordset.EOF Then
NewRecordset.MoveNext
End If
Next m
cn.CommitTrans
dc.DeleteGeoDataset (tempFileName)
'Add to layer's tag, this gonna used for address matching
Set lyr = New MapObjects2.MapLayer
Set lyr.GeoDataset = dc.FindGeoDataset(lyrname)
lyr.Tag = "[SHAPEFILE]" & lyrpath & "|" & lyrname
CurMap.Layers.Add lyr
dc.Disconnect
cn.Close
Set dc = Nothing
Set cn = Nothing
frmMeasurement.MousePointer = 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|