ActiveX/COM problem
Aric Whitaker
aric at pccrafter.com
Tue Jun 3 10:28:15 CDT 2003
Actually, anytime I pass ANY variable to a Field object, it crashes...
says it cannot find that field. So, this works:
vField = vCursor.Field( 1 )
But this does NOT:
Dim myInt as Integer
myInt = 1
vField = vCursor.Field( myInt )
It’s a real head-banger... And it is in VBScript under .NET... go
figure.
-----------------------------------
For anyone that wants to help:
If you have IIS, and have installed the .NET architecture (free update
from M$), then you can run the following code. Save it out as an ASPX
file, and hit it in on your web service... you will also need to edit
the path to a valentine DB file.
Also, to register the VCOM.dll, go to a command prompt on the web
machine, and type:
Regsvr32 VCOM.dll
--------BEGIN vTest.aspx --------------
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<SCRIPT RUNAT="server">
Sub Page_load( s As Object, e As EventArgs )
Dim Valentina
Dim vDB
Dim vCursor
Dim vField
Dim strReturn As String
Dim intCounter As Integer
Dim intC As Integer
Dim strTemp As String
Dim fldCount As Integer
Dim strSQL As String
Dim dbPath As String
'Variables for use in DataTable
Dim dTable As DataTable
Dim dColumn As DataColumn
Dim dRow As DataRow
'''''''''''''''''''''''''''
'Edit these strings
'''''''''''''''''''''''''''
strSQL = "SELECT * from table1 "
dbPath = "c:\inetpub\mywebsite.com\valentina\db\mydatabase.vdb"
'Open ActiveX Control
Valentina = Server.CreateObject( "VCOM.Valentina.1" )
'Initialize Valentina
Valentina.Init ( 3, strRegCode )
Valentina.DebugLevel = 2
'Create DB object
vDB = Server.CreateObject( "VCOM.VDataBase.1" )
'Open the Database
vDB.Open( dbPath )
'Create a Cursor
vCursor = vDB.SQLSelect( strSQL )
vCursor.FirstRecord
'Create the datatable
dTable = New DataTable( "tempDataTable" )
fldCount = vCursor.FieldCount
For intC = 1 to fldCount
vField = vCursor.Field( intC ) ''''' This is where she
crashes!
strTemp = vField.Name
dColumn = New DataColumn( strTemp, getType( String ) )
dTable.Columns.Add( dColumn )
Next
For intCounter = 1 to vCursor.RecordCount
'Insert Data from Cursor into a DataRow
dRow = dTable.NewRow()
'Loop through all the fields, setting their values
For intC = 1 to vCursor.FieldCount
dRow( vCursor.Field( intC ).Name ) =
vCursor.Field( intC ).Value
Next
dTable.Rows.Add( dRow )
vCursor.NextRecord()
Next
'Shutdown the database
vDB.Close()
Valentina.ShutDown()
'Clear memory
vCursor = nothing
vDB = nothing
Valentina = nothing
End Sub
</SCRIPT>
--------END vTest.aspx ----------------
> -----Original Message-----
> From: valentina-bounces at lists.macserve.net [mailto:valentina-
> bounces at lists.macserve.net] On Behalf Of Ruslan Zasukhin
> Sent: Tuesday, June 03, 2003 2:09 AM
> To: valentina at lists.macserve.net
> Subject: Re: ActiveX/COM problem
>
> on 6/3/03 0:50, Aric Whitaker at aric at pccrafter.com wrote:
>
> > Here is the source code in VBScript, and I error out everytime when
I
> > try to reference vCursor.Field(intC)... any ideas?
> >
> > --------ASP.NET code ---------------------
> >
> > fldCount = vCursor.FieldCount
> >
> > For intC = 1 to fldCount
> > vField = vCursor.Field(intC)
> ^^^^^^^^ this line give error?
> check that Vcursor exists.
>
> > strTemp = vField.Name
> > Next
> >
> > -------------------------------------------
>
>
> Hmm, I think your cursor exists, because you use it before.
> vCursor.FieldCount
>
> Strange.
>
> Try access a field by name, just to see if this make difference.
>
> You work in Visual BASIC now?
> Then you can send project to me for testing that reproduce problem.
>
> --
> Best regards,
> Ruslan Zasukhin [ I feel the need...the need for speed ]
> -------------------------------------------------------------
> e-mail: ruslan at paradigmasoft.com
> web: http://www.paradigmasoft.com
>
> To subscribe to the Valentina mail list go to:
> http://lists.macserve.net/mailman/listinfo/valentina
> -------------------------------------------------------------
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003
More information about the Valentina
mailing list