生如火花 发表于 2005-3-31 10:53:38

[求助]谁能给一个通过ODBC函数读取db的实际例子,多谢了

robot自带的例子看不懂啊
connection = SQLOpen("DSN=SblTest", outputStr, prompt:=5)
这个里面的DSN=SblTest是怎么连结数据库的,不懂啊,求教大家了。

司空公子 发表于 2005-3-31 14:16:46

在控制面板的管理工具里的数据源配置DSN

生如火花 发表于 2005-3-31 14:25:45

明白了,谢谢

pcl2004_27 发表于 2005-4-1 22:15:18

我这里有个代码的例子,你可以参考下,很简单!但是完全可以说明问题!
代码如下:

Sub main
' Declarations
'
    Dim outputStr As String
    Dim connection As Long
    Dim prompt As Integer
    Dim datasources(1 To 6,1 to 9) As Variant
    Dim retcode As Variant
   
    Dim iProcColumns As Integer
    Dim iProcRows As Integer
    Dim iProcRowCount As Integer
    Dim iProcColumnCount As Integer
    Dim sFunctionCall As String

    prompt = 2
    connection = SQLOpen("DSN=RationalTest", outputStr, prompt:=2)
    retcode = SQLExecQuery(connection:=connection,query:="select * from product ")
    retcode = SQLRetrieve(connection,datasources())
   
    For iProcRowCount = 1 to 10
      .
      For iProcColumnCount = 1 to 6
                  sFunctionCall = datasources(iProcRowCount, iProcColumnCount)
      Next iProcColumnCount


    Next iProcRowCount
    retcode = SQLClose(connection)


End Sub

生如火花 发表于 2005-4-2 14:13:40

获益非浅~~

tongfenglcz 发表于 2005-7-26 10:02:48

Sub main
' Declarations
'
    Dim outputStr As String '请问这里定义的变量是干什么啊?
    Dim connection As Long
    Dim prompt As Integer'请问这里的prompt是什么意思?
    Dim datasources(1 To 6,1 to 9) As Variant'这又指什么呢?
    Dim retcode As Variant'这是干嘛的?
   
    Dim iProcColumns As Integer
    Dim iProcRows As Integer
    Dim iProcRowCount As Integer
    Dim iProcColumnCount As Integer
    Dim sFunctionCall As String

    prompt = 2 ’为什么是2?什么意思?
    connection = SQLOpen("DSN=RationalTest", outputStr, prompt:=2)
    retcode = SQLExecQuery(connection:=connection,query:="select * from product ")
    retcode = SQLRetrieve(connection,datasources())
   
    For iProcRowCount = 1 to 10
      .
      For iProcColumnCount = 1 to 6
                  sFunctionCall = datasources(iProcRowCount, iProcColumnCount)
      Next iProcColumnCount


    Next iProcRowCount
    retcode = SQLClose(connection)


End Sub

能不能详细讲解一下比较笨呢 这方面的基础比较弱
谢谢

viviv_wang 发表于 2006-4-5 17:59:59

good,同上,不是很明白。

oftime999 发表于 2007-6-2 16:00:55

Q:Dim datasources(1 To 6,1 to 9) As Variant'这又指什么呢?
A:定义一个二维数组。即6行9列。

oftime999 发表于 2007-6-2 16:07:02

Q: Dim retcode As Variant'这是干嘛的?
A: retcode = SQLExecQuery(connection:=connection,query:="select * from product ")'执行查询
    retcode = SQLRetrieve(connection,datasources())'取回结果,结果存入二维数组

tt2008 发表于 2008-8-1 23:55:39

hao
页: [1]
查看完整版本: [求助]谁能给一个通过ODBC函数读取db的实际例子,多谢了