Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a dictionary object in UFT (VBScript) where it contains items that is array. I want to know how to iterate thru every element in that array item that is refered by key.
Below is the example of my dictionary having items that is array
Set NodeValues = CreateObject("Scripting.Dictionary")
NodeValues.Add "Nodename", Array("EMS", "ACM")
NodeValues.Add "MSW", Array("0x31,0x32,0x33,0x34" , "0x25,0x25,0x12,0x12")
NodeValues.Add "SBL", Array("0x35,0x32,0x30,0x31" , "0x45,0x55,0x22,0x92")
NodeValues.Add "Data", Array(array("0x21,0x21,0x21", "0x11,0x11,0x22") , array("0x45,0x55,0x22,0x92","0x25,0x65,0x25"))
Since this dictionary is generated dynamically am not sure how many elements it will have in array. Now i need to loop thru all the elements in array to find my required elements
For example. How do I iterate thru all the elements in Array of Nodename ( key) untill i find EMS. I tried different ways to access but no success.
Please help me with solution.
To check if "EMS" is found in the array stored for the key Nodename, you can check the following code:
For Each element In NodeValues.Item("Nodename")
If StrComp(element, "EMS", 1) = 0 Then
MsgBox "found"
Exit For
End If
Next
To get the Index:
arrTemp = NodeValues.Item("Nodename")
blnFound = False
For i = 0 To UBound(arrTemp)
If StrComp(arrTemp(i), "EMS", 1) = 0 Then
blnFound = True
Exit For
End If
Next
If blnFound Then
MsgBox "Index: " & i
Else
MsgBox "Not found"
End If
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 months ago.
Improve this question
I am using Insight.Database version 6.3.10 for SQL Server ORM, using C# as the client. I have a run into an issue where the mapping does not return a correct value for money column data type. I am using decimal in C# client. Below is the sample code:
DROP TABLE IF EXISTS dbo.MyTestTable;
CREATE TABLE dbo.MyTestTable
(
AmountToAllocate MONEY
)
GO
INSERT INTO dbo.MyTestTable VALUES(177279.73)
GO
CREATE OR ALTER PROC [dbo].[MyTestProc]
AS
BEGIN
SELECT TOP 1 m.AmountToAllocate FROM dbo.MyTestTable m
END
GO
I have an object in C# client:
public class MyTestResponse
{
public decimal AmountToAllocate { get; set; }
}
Now, if I execute the store proc with Insight.Database, the returned object has AmountToAllocate property, but its value is 0, instead of 177279.73.
I have no idea what went wrong, and why the mapping does not work properly.
Does anyone know how to resolve it? Thank you
Despite you solving your own problem, for reference for anyone else in the future, you can find all of the SQL Server data type mappings in C# in SQL Server Data Type Mappings.
Money maps to Decimal.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I'm currently working on a webpage using ASP Classic.
I have created an If statement, if the company id is equal to 1, then the variable receives a connection.execute.
Else, the variable must receive an fixed value of 1.
For some reason it's not working. I've tried to google the correct syntax for such case, but I haven't been successful... here is the part of the code I have just told you guys about:
<%
Dim integrated_code
if SESSION("Company_ID") = 1 Then
set integrated_code = connection.execute("SELECT TOP 1 ID_BLABLABLA FROM BLABLABLA")
Else
set integrated_code = 1
End if
%>
Lose the "set", at least for the simple variable. The other one depends on the nature of "connection".
<%
Dim integrated_code
If Session("Company_ID") = 1 Then
Set integrated_code = connection.execute("...")
Else
integrated_code = 1
End If
%>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Hi I try to call some data using API but it shows error message of "invalid key". But In the function I didn't figure out where I can input my key. The code is shown below:
sahie_years <- getCensus(
name = "timeseries/healthins/sahie",
vars = c("NAME", "PCTUI_PT"),
region = "state:01",
time = "from 2006 to 2018")
head(sahie_years)
Can anybody have some ideas?
See documentation here for setting up your API key.
You need to sign up for an API key here.
Once you've done that you can either specify your API key by setting an environment variable using Sys.setenv(CENSUS_KEY="YOUR_CENSUS_KEY_GOES_HERE"), or
just set it directly in your getCensus call by adding the argument key = "YOUR_CENSUS_KEY_GOES_HERE".
For API keys in general, it is often easiest to set them in a .Renviron file, which will make them available in each session using Sys.getenv.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am trying to pass in the following 2d array of data into a field of a document using Cloud Functions.
[ [ '-LXRXPFgA6sC9Mg0GQMt', 1, 'Sushi premium' ], [ '-LXRSAp3jpB8EUbZU-0c', 1, 'Caramel Glazed Donuts' ] ]
The error I got is:
>Error: 3 INVALID_ARGUMENT: Cannot convert an array value in an array value.
at Object.exports.createStatusError (/user_code/node_modules/firebase-admin/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:845:24)
Nested arrays are not supported in Cloud Firestore. You can store arrays of objects, and those objects can have fields that are arrays, but multi-level arrays are not possible.
You would need to change your data to look something more like:
[
{"id": "-LXRXPFgA6sC9Mg0GQMt","number":1,"label":"Sushi premium"},
// ...
]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Improve this question
I have around 100 rows in MS Access, each row includes an attachment. Using RODBC in R I can access the table but have no idea how to access attached files and download them in R
could you plz help me how to do it
Attachments in MS Access are special data types that actually involve nested tables for metadata (filename and filedata) information. Hence, you cannot access this data with DML SQL statements alone via RODBC but can using a COM interface, specifically connecting to the DAO SaveToFile() method.
Consider the following using the RDCOMClient package which allows interfacing to the Access Object Library. Do note: in order to run the below code, you must have MSAccess.exe (the MS Office GUI program) installed and not just the .accdb file. In the SQL query below, ColAttach is the name of the attachment field in your table and you must use those qualifiers .filedata and .filename. DAO recordset field numbers are zero based (hence the 0 and 1).
library(RDCOMClient)
# INITIALIZING OBJECTS
accApp <- COMCreate("Access.Application")
accApp$OpenCurrentDatabase("C:\\Path\\To\\Database.accdb")
docmd <- accApp[["DoCmd"]]
db <- accApp$CurrentDb()
rst <- db$OpenRecordset("SELECT ColAttach.filedata, ColAttach.filename FROM TblAttach")
while(rst$EOF() == FALSE){
rst$Fields(0)$SaveToFile(paste0("C:\\Path\\To\\Output_", rst$Fields(1)$Value()))
rst$MoveNext()
}
# CLOSING OBJECTS
rst$close()
docmd$CloseDatabase()
accApp$Quit()
# RELEASING RESOURCES
accApp <- db <- docmd <- rst <- NULL
rm(rst, db, accApp)
gc()
For multiple attachments, loop through the child recordset on each filename and filedata values (notice the different SQL). Be sure to check if file exists and destroy accordingly else you will receive a COM error:
rst <- db$OpenRecordset("SELECT ID, ColAttach FROM TblAttach")
while(rst$EOF() == FALSE){
childRS <- rst[['ColAttach']]$Value()
while(childRS$EOF() == FALSE){
if (file.exists(paste0("C:\\Path\\To\\Output_", childRS[["filename"]]$Value()))) {
unlink(paste0("C:\\Path\\To\\Output_", childRS[["filename"]]$Value()))
}
childRS[["filedata"]]$SaveToFile(paste0("C:\\Path\\To\\Output_",
childRS[["filename"]]$Value()))
childRS$MoveNext()
}
rst$MoveNext()
}