Vba

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nkgadi
    New Member
    • Sep 2006
    • 1

    #1

    Vba

    Hi there

    i need to populate the array, with the values from recordset.
    Dim Wxdbs As database
    Dim Wxrecordset As Recordset

    Dim WxArr(4) As Variant

    Set .AdoConn = New ADODB.Connectio n
    AdoConn.connect ingstring = " Server=zzzzzzDr iver=SQLServer Database=zzzz userid=zzzz pwd=zzzz

    Dim strSelect As String
    strSelect = "Select Datetime,tagnam e,value from dbo.anahistory where tagname='108_ws ' or tagname='108_te mp2' or tagname='108_wd '"

    Set WxArr = New ADODB.Recordset
    Wxrecordset.Ope n strSelect, AdoConn, adOpenStatic

    WxArr(1) = Datetime
    WxArr(2) = Winddirection
    WxArr(3) = WindSpeed
    WxArr(4) = temperature

    Thank you in advance
  • CaptainD
    New Member
    • Mar 2006
    • 135

    #2
    Originally posted by nkgadi
    Hi there

    i need to populate the array, with the values from recordset.
    Dim Wxdbs As database
    Dim Wxrecordset As Recordset

    Dim WxArr(4) As Variant

    Set .AdoConn = New ADODB.Connectio n
    AdoConn.connect ingstring = " Server=zzzzzzDr iver=SQLServer Database=zzzz userid=zzzz pwd=zzzz

    Dim strSelect As String
    strSelect = "Select Datetime,tagnam e,value from dbo.anahistory where tagname='108_ws ' or tagname='108_te mp2' or tagname='108_wd '"

    Set WxArr = New ADODB.Recordset
    Wxrecordset.Ope n strSelect, AdoConn, adOpenStatic

    WxArr(1) = Datetime
    WxArr(2) = Winddirection
    WxArr(3) = WindSpeed
    WxArr(4) = temperature

    Thank you in advance
    Are you getting errors?
    have you stepped through your code to see if your recordset is populating?
    If you step through your code and hold the cursor over the values you are placing in the array, do you see a value?

    WxArr(4) = temperature should be WxArr(4) = Wxrecordset!tem perature
    or
    WxArr(4) = temperature should be WxArr(4) = Wxrecordset.Fie ld("temperature ").Value

    Comment

    Working...