Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO Problem
Message
From
15/10/2004 16:56:17
 
 
To
15/10/2004 16:42:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00951852
Message ID:
00951855
Views:
4
Hi all,
Make sure the revert the "_ADO_" keyword that have been expanded when the original message was posted.

>Hi all,
>
>I can run this code snippet from one machine without problem but generates an error on another machine. The error occurs in the oCommand.Execute() line.
>I have VFP 7, 8, 9 Beta on my machine. VFP8 is the registered version in Windows. I probably have several versions of MDAC installed as well. I was hoping that to get feedbacks from anyone who can run it with or without problems and possibly help me point to the source of problem. Thanks in advance. Here is the code:
>
>
>#define AD_CONN_STRING_DEFAULT "Provider=VFPOLEDB.1;Data Source=DATA2.DBC;Password='';Collating Sequence=MACHINE;"
>close databases all
>
>on error x = .t.
>delete file data2.*
>delete file hwp.*
>delete file wh.*
>delete file pr.*
>on error
>
>create database data2
>create table hwp (hid i, wid i, pid i, demand i)
>insert into hwp values (10,1,1,100)
>insert into hwp values (10,2,1,80)
>insert into hwp values (10,3,1,70)
>insert into hwp values (10,4,1,60)
>insert into hwp values (10,1,2,80)
>insert into hwp values (10,2,2,20)
>insert into hwp values (10,3,2,30)
>insert into hwp values (10,4,2,50)
>
>create table wh (wid i, wname c(10))
>insert into wh values (10, "hub")
>insert into wh values (1, "wh1")
>insert into wh values (2, "wh2")
>insert into wh values (3, "wh3")
>insert into wh values (4, "wh4")
>
>create table pr (pid i, pname c(10))
>insert into pr values (1, "pr1")
>insert into pr values (2, "pr2")
>
>close databases all
>
>oCA = createobject('clsCA')
>oCA.RunCommand("create view vw_wp as select hid,wid,pid,demand from hwp where wid=1")
>oCA.ExtractData("select * from vw_wp")
>select (oCA.alias)
>browse
>close databases all
>oCA = null
>
>*-----------------------------------------------------
>define class clsCA as cursoradapter
>
>   datasourcetype = 'ADO'
>   flags = 0
>   fetchasneeded = .t.
>   prepared = .f.
>
>   *--------------------------------------------------
>   procedure ExtractData(cCommandText, cAlias)
>
>      local loConnDataSource
>      set multilocks on
>
>      loConnDataSource = createobject('ADODB.Connection')
>      loConnDataSource.ConnectionString = AD_CONN_STRING_DEFAULT
>      loConnDataSource.open()
>
>      this.datasource = createobject('ADODB.RecordSet')
>      this.datasource.CursorLocation   = 3  && adUseClient
>      this.datasource.LockType         = 3  && adLockOptimistic
>      this.datasource.ActiveConnection = loConnDataSource
>      this.SelectCmd = cCommandText
>      this.Alias = iif(type('cAlias')='C' and !empty(cAlias), cAlias, sys(2015))
>
>		if !this.CursorFill()
>			for each oError in oCommand.ActiveConnection.Errors
>				? oError.Description
>			endfor
>		endif
>
>      loConnDataSource.close()
>
>      return .t.
>
>   endproc
>
>   *--------------------------------------------------
>	procedure RunCommand(cCommandText)
>
>      local loConnDataSource
>      set multilocks on
>
>      loConnDataSource = createobject('ADODB.Connection')
>      loConnDataSource.ConnectionString = AD_CONN_STRING_DEFAULT
>      loConnDataSource.open()
>		
>		oCommand = createobject('AdoDb.Command')
>		oCommand.CommandText = cCommandText
>		oCommand.ActiveConnection = loConnDataSource
>	
>		local loExc as Exception
>		try
>			oCommand.Execute()
>		catch to loExc
>			for each oError in oCommand.ActiveConnection.Errors
>				? oError.Description
>			endfor
>		finally
>		endtry
>
>	endproc
>
>enddefine
>
ramil
~~ learning to stand still
Previous
Reply
Map
View

Click here to load this message in the networking platform