Private Function DataLoad(F2 As Integer, F3 As Fields)    Dim Crr As String
    Dim Arr() As String
    
    
    a = ""
    Crr = ""
    
    
    For j = MSHFlexGrid1.Rows - 1 To 1 Step -1
     
     a = a & MSHFlexGrid1.TextMatrix(j, F2)
       Next
    
    Arr = Split(a, vbTab)
    For y = 0 To UBound(Arr)
    
    Adodc1.Recordset(F3) = Arr(y)
      Next
    
End FunctionPrivate Sub Command2_Click()
 Call DataLoad(2, 1)
  
Call DataLoad(3, 2)
  
End Sub
 这里Adodc1.Recordset(F3) = Arr(y)部分哪儿错了呢 这样做会不会同时能够添加到多个字段呢

解决方案 »

  1.   

    看样子F3是一个自定义的数据类型,F3应有多个字段,那么Adodc1.Recordset(F3)是什么了?
      

  2.   

    看样子F3是一个自定义的数据类型,F3应有多个字段,那么Adodc1.Recordset(F3)是什么了? 队,应该有多个字段。我想用
    Private Sub Command2_Click() 
    Call DataLoad(2, 1) 
      
    Call DataLoad(3, 2) 
      
    End Sub 这个来指定每个字段值。
      

  3.   

    Adodc1.Recordset(F3) 参数类型错,应该是 字符串 或 数字,Arr(y)是你的自定义函数吧还有Adodc1.Recordset(F3)=Arr(y) 也不能这么写啊,你想做么呢?
      

  4.   


      Adodc1.Recordset(F3)=Arr(y)  Arr(y) 数据添加到记录集Recordset()相应字段里。
      

  5.   


    '我的数据库中有一个表 表名: 表1
    '表中有二个字段:  字段A 与 主键
    '以下调试通过.
    '将 MSHFlexGrid1 中第一列的数据都复制至 表1 的 字段A 中.
    '使用的时候请注意. Adodc1 打开的数据库必须要有主键. 即要有一列必须是不重复的,必须的.
    Private Sub Command1_Click()
      MSHFlexGrid1.TextMatrix(1, 1) = "logreve"
      DataLoad 1, "字段A"
    End Sub
    Private Function DataLoad(F2 As Integer, F3 As Variant)
       
       Dim CCount As Long
       
       If MSHFlexGrid1.Rows - 1 > Adodc1.Recordset.RecordCount Then
          CCount = Adodc1.Recordset.RecordCount
       Else
          CCount = MSHFlexGrid1.Rows - 1
       End If
          
     
        Adodc1.Recordset.MoveFirst
        For j = 1 To CCount
           Adodc1.Recordset.Fields(F3).Value = MSHFlexGrid1.TextMatrix(j, F2)
           Adodc1.Recordset.Update
           Adodc1.Recordset.MoveNext
        NextEnd Function
      

  6.   

    你可以再修改一下.
    当 MSHFlexGrid1 比数据库中的行数还要多的时候,让数据库增加行.并赋值.
      

  7.   

    Private Function DataLoad(F2 As Integer, F3 As Integer)    Dim Crr As String
        Dim Arr() As String
        
        
        a = ""
        Crr = ""
        
        
        For j = MSHFlexGrid1.Rows - 1 To 1 Step -1
        
                a = a & MSHFlexGrid1.TextMatrix(j, F2)
        Next
        
        Arr = Split(a, vbTab)
        
        For y = 0 To UBound(Arr)
        
            'Adodc1.Recordset.AddNew     '新增时
            Adodc1.Recordset.Fields(F3) = Arr(y)
            Adodc1.Recordset.Update
        Next
        
    End FunctionPrivate Sub Command2_Click()
    Call DataLoad(2, 1)
      
    Call DataLoad(3, 2)