07-31-2019 10:05 AM - edited 07-31-2019 11:01 AM
I was looking for a way to store the names of the channels coming from my database --> to the channel, but its not working.
I tried something like this:
set oChnXname = data.Root.ChannelGroups("Exp Channel group").Channels.Add("ChnXname",Datatypestring) oChnXname(i)=(RS.fields("xchannel"))
Any help is highly appreciated
Thanks in Advance.
Solved! Go to Solution.
07-31-2019 10:21 AM
You create a new channel oChnXname. What is the value of "i"? If it is 0 that won't work. Also, nee to use oChnXname.Values(i). Also, no idea what RS object is.
07-31-2019 11:00 AM
'i' is:
i=1 to rowcount(RS) ' RS is the record set obj for the data coming from DB
07-31-2019 11:06 AM
Possible reasons why doesn't work:
1. You use channel(i) instead of channel.Values(i)
2. (RS.fields("xchannel")) is not returning you a String type. Try converting it to String.
3. (RS.fields("xchannel")) is empty
It is hard to know what the exact issue is since you haven't showed an error message or wrong output of your existing script
07-31-2019 11:23 AM
I tried:
oChnLimit.Values(i)=(RS.fields("limit"))
and it throws this error
1. tried
2. data in the database is of varchar type, so i used data type string while creating channel
set oChnLimit = data.Root.ChannelGroups("Exp Channel group").Channels.Add("ChnLimit",Datatypestring)
3. no, its not empty
07-31-2019 11:44 AM
yes so the error message says that you are trying to put a vbObject into the string channel you created. You must have some sort of loop to assign each value from RS (table?) to a value in your new channel
Like:
If not RS.EOF Then RS.MoveFirst Do While not RS.EOF Call LogFileWrite(RS.Fields("limit")) RS.MoveNext Loop End If
Will that log strings? or do you need to do something like RS.GetString?
07-31-2019 01:11 PM - edited 07-31-2019 01:57 PM
Not sure if i need to log strings , but i tried to assign it to a temporary variable and then assigned that to obj, channel is referring to and it worked out.
Dim tempA tempA=RS.fields("xchannel") oChnXname(i)=tempA