must declare the scalar variable "#nInstID" [duplicate] - asp.net

This question already has answers here:
Must declare the scalar variable
(11 answers)
must declare the scalar variable '#custid' using dbcontext.Database.SqlQuery?
(2 answers)
Closed 4 years ago.
I am using a ADO.NET Entity Data Model for accessing my tables and stored procedure. I mapped stored procedure to my Room table as it returning sfloor column. In Entity Framework, my get request method for floor is:
public List<Floor> GetFloorList(long instID,long userID,string userRole, long buildID, long deptID)
{
try
{
var floors = dbdata.Database.SqlQuery<Room>("GetUserFloorList #nInstID, #nUserID, #sUserRole, #nBuildID, #nDeptID", instID, userID, userRole, buildID, deptID);
List<Floor> floorList = new List<Floor>();
foreach (var fl in floors)
{
Floor floor = new Floor();
floor.floorName = fl.sFloor;
floorList.Add(floor);
}
return floorList;
}
catch(Exception)
{
throw;
}
}
As I want to list out all the floor name which belongs to corresponding parameters. But when I am running this method it giving me above error.
As per some solution I need to mention data types of each variable but I am not sure how to do that. Can anyone tell me what to do?
Thanks in advance.

Instead of passing parameters with your variable directly, you have to use new SqlParameter("#nInstID", instID) and do this for all your parameters.

Related

How to extract a string value from an array using scripted field in kibana?

Is there a way to extract a string value from an array with the use of if statement in scripted field in kibana. I tried the below code, however, I am unable to filter out the correct and incorrect values in discover tab of kibana. This might be due to remark field is an array.
def result_string = "";
if (doc['nac.keyword'].value =="existing_intent" &&doc['remark.keyword'].value != "acceptable") {
result_string = "incorrect";
}
if (doc['nac.keyword'].value =="existing_intent" &&doc['remark.keyword'].value == "acceptable") {
result_string = "correct";
}
return result_string;`
You can use the contains method defined on Array to check for element membership:
!doc['remark.keyword'].value.contains("acceptable") //does not contain
For this, you might want to ensure first that doc['remark.keyword'].value is indeed an Array.

DoGet with multiple parameters not being recognized

I'm currently trying to connect a Lua Script with a GS WebApp. The connection is working but due to my lack of knowledge in GScripting I'm not sure why it isn't saving my data correctly.
In the Lua side I'm just passing in a hard-code a random name and simple numerical userid.
local HttpService = game:GetService("HttpService")
local scriptID = scriptlink
local WebApp
local function updateSpreadSheet ()
local playerData = (scriptID .. "?userid=123&name:Jhon Smith")
WebApp = HttpService:GetAsync(playerData)
end
do
updateSpreadSheet()
end
On the Google Script side i'm only saving the data on the last row and then add the value of the userid and the name.
function doGet(e) {
console.log(e)
// console.log(f)
callName(e.parameter.userid,e.parameter.name);
}
function callName(userid,name) {
// Get the last Row and add the name provided
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(sheet.getLastRow() + 1,1).setValues([userid],[name]);
}
However, the only data the script is saving is the name, bypassing the the userid for reasons I have yet to discover.
setValues() requires a 2D array and range dimensions should correspond to that array. The script is only getting 1 x 1 range and setValues argument is not a 2D array. Fix the syntax or use appendRow
sheet.getRange(sheet.getLastRow() + 1,1,1,2).setValues([[userid,name]]);
//or
sheet.appendRow([userid,name])
References:
appendRow

How do I get a value from a dictionary when the key is a value in another dictionary in Lua?

I am writing some code where I have multiple dictionaries for my data. The reason being, I have multiple core objects and multiple smaller assets and the user must be able to choose a smaller asset and have some function off in the distance run the code with the parent noted.
An example of one of the dictionaries: (I'm working in ROBLOX Lua 5.1 but the syntax for the problem should be identical)
local data = {
character = workspace.Stores.NPCs.Thom,
name = "Thom", npcId = 9,
npcDialog = workspace.Stores.NPCs.Thom.Dialog
}
local items = {
item1 = {
model = workspace.Stores.Items.Item1.Main,
npcName = "Thom",
}
}
This is my function:
local function function1(item)
if not items[item] and data[items[item[npcName]]] then return false end
end
As you can see, I try to index the dictionary using a key from another dictionary. Usually this is no problem.
local thisIsAVariable = item[item1[npcName]]
but the method I use above tries to index the data dictionary for data that is in the items dictionary.
Without a ton of local variables and clutter, is there a way to do this? I had an idea to wrap the conflicting dictionary reference in a tostring() function to separate them - would that work?
Thank you.
As I see it, your issue is that:
data[items[item[npcName]]]
is looking for data[“Thom”] ... but you do not have such a key in the data table. You have a “name” key that has a “Thom” value. You could reverse the name key and value in the data table. “Thom” = name

Flink: enrich a data set with a new column based on some computation

I am trying to do a simple processing with a data set.
Consider a data set with two columns of type String. To this data set I want to add a third column of type Long, which accumulates the number of records so far seen in the data set.
Example:
Input:
a,b
b,c
c,d
Output:
a,b,1
b,c,2
c,d,3
I have tried the following solution but I get a strange result:
DataSet<Tuple2<String, String>> csvInput = env.readCsvFile("src/main/resources/data_file")
.ignoreFirstLine()
.includeFields("11")
.types(String.class,String.class);
long cnt=0;
DataSet<Tuple3<String, String, Long>> csvOut2 = csvInput.map(new MyMapFunction(cnt));
private static class MyMapFunction implements MapFunction<Tuple2<String, String>, Tuple3<String, String, Long>> {
long cnt;
public MyMappingFunction(long cnt) {
this.cnt = cnt;
}
#Override
public Tuple3<String, String, Long> map(Tuple2<String, String> m) throws Exception {
Tuple3 <String ,String, Long> resultTuple = new Tuple3(m.f0,m.f1, Long.valueOf(cnt));
cnt++;
return resultTuple;
}
}
When I apply this solution for a file with 100 entries I get a count of 47 instead of 100. The counter is restarted at 53. Similarly, when I apply it for even a larger file the counter is somehow reset from time to time so I don't get the total number of the lines.
Could you please explain why is my implementation behaving in this way? Also, what could be a possible solution to my problem?
Thanks!
This is a multithreading issue. How many tasks slots do you have?
I had to clean up your code before running it - I suggest posting full working examples in future so that you have a chance of getting more answers.
The way you are keeping track of the count is not thread-safe, and so if you have more than one task slot you will have problems with the count value being inaccurate.
The proper way to count, as shown in the data artisans word count example, would be to use the 3rd slot in your tuple to simply store the value 1, and then sum the dataset.
resultTuple = new Tuple3(m.f0,m.f1, 1L);
then
csvOut2.sum(2).print();
where 2 is the index of the tuple containing the value 1.

Cannot Solve "index was outside the bounds of the array"

I am working in C# with ASP.NET. I am familiar with this error but this time I can't solve it.
I have text in a drop-down list like this:
राम कुमार सिंह 8s2w8r
here राम कुमार सिंह is the name in HINDI while 8s2w8r is users' ID.
I need to separate these two values and need to pass them as session variables. The logic I am using is depicted in the code.
public string reverse(string s)
{
char []temp=s.ToCharArray();
Array.Reverse(temp);
return (temp.ToString());
}
string dropdowntextreversed=reverse(DropDownList1.Text);
char []delim=new char[]{' '};
string []parts=dropdowntextreversed.Split(delim,2);
string family_head_uid = reverse(parts[0]);
string family_head = reverse(parts[1]);
Session.Add("family_head", family_head);
Session.Add("family_head_uid", family_head_uid);
Response.Redirect("/WebForm1.aspx");
I always get an error as the index was outside the bounds of the array! I don't understand this because I am breaking the string into 2 parts so it should have parts[0] and parts[1]. Please suggest...
You are splitting the string into MAXIMUM 2 parts, but if there's only one you will get probably one part.
Read this documentation
Try to assert that parts.Length is == 2 or to access elemnts only there atre two elements
Try this link. As I think there is a problem in the temp.ToString() which will return System.Char[] rather than the value which are you looking for. Use string.join instead will work.
Use the following reverse method:
public string reverse(string s)
{
return String.Join(String.Empty, s.ToCharArray().Reverse());
}

Resources