如何在FoxPro 9上连接Oracle数据库11g服务器

时间:2014-03-18 19:59:00

标签: oracle11g visual-foxpro

如何在FoxPro中连接远程oracle数据库11g服务器?

1 个答案:

答案 0 :(得分:2)

如果安装了数据提供程序,它应该相对简单。

I would start by looking at the connection string requirements

有了这个,你可以通过

获得数据库的句柄
cConnectionString = "Driver = blah;Server=blah; etc from connection string website reference";
nHandle = SQLStringConnect( cConnectionString )

if nHandle < 1
   messagebox( "Unable to connect" )
   return
endif

*/ Once connected, you can then query the database
nResult = SQLExec( nHandle, "select * from yourTable", "cursorResultSentBackToVFPSide" )

if nResult < 1
   messagebox( "Error querying data" )
   return
endif

*/ If you need to parameterize something, a local variable in your routine can be used 
*/ and will be applied by using the "?" place-holder, such as

lnSomeIDYouWant = 1234
lcSQLCmd = "select * from SomeTable where SomeKey = ?lnSomeIDYouWant order by blah"
nResult = SQLExec( nHandle, lcSQLCmd, "C_VFPAlias" )

SQLDisconnect(nHandle)

参数几乎可以是任何类型(除了通用/二进制等可能需要替代措施的东西,但其他参数如逻辑,数字,日期,字符串都没有问题)。