I'm trying to query a site collection for documents of a certain user
the query works fine, but the columns in datatable returned are all string columns,
and when you try to sort a column which represents a number - the sort result
is wrong.
is there a way to get the datatable with actual columns type?
Related
I've tried to find a solution to this, but can't seem to find anything that quite matches my goal here. The answers I've found are either C# or are wanting the data to go from the DGV to the DT.
I have a datatable, which is built out using an SQL query. In this data table, I have a column "Lab ID" that I want to use as a search index. On my front end, there is a requirement for the Lab ID to be supplied. When the Lab ID is entered, the data table should be searched, and the resulting row (entire row) should be added to the datagridview. Each scan should add a row and not overwrite. I have specified the DGV columns at form load but would like it to grab the column names from the table if possible.
Here is my current front end - noting that the left datagridview is only temporary to confirm the data is coming out of SQL and references the same datatable I am wanting to use for the right DGV. The user will pick the dates, enter the Lab ID, then click Check. If the Lab ID checks out, it should be added.
The other thing I'll need to able to do is compare the results in the data table with what is in that datagridview - if an item in the table is missing in the datagridview, I need to be able to retrieve the missing Lab IDs (don't need the whole row for this one) and add those missing Lab IDs to a messagebox.
I don't have any code at this point because I've not found anything that works, with the exception of this:
dgScanned.Rows.Add(GetResults.Rows)
Which results in the string 'System.Data.DataRowCollection' being added to the 'Request ID' column.
I have a table that contains the column "FEEDDATA". In FEEDDATA column the values stored in json object. Now i want make a serach and fetch the data where "AuthorFirstName" key in FEEDDATA column have value "Lalit". I need to implement it in LINQ.
e.g f.FeedData.AuthorFirstName.contains("%Lal%")
In short: I need to implement search on the feedata column and fetch only those records in which key AuthorFirstName contains text "lal" .
Please help.
Using general LINQ to SQL, you can use the Contain method to do a LIKE SQL search and find matching records:
var ans = db.Where(r => r.FEEDDATA.Contains("\"AuthorFirstName\":\"Lalit\""));
Assuming the type of FEEDDATA is actually e.g. varchar and not a database specific special JSON type.
I have a scenario like this where this particular column "workData" has some JSON in string form. I have to find records where Text is either empty or the Text of both objects are same. For the empty string case I can apply a where clause as WHERE workData not like '%"Text":""%' but I am clueless as to how to do the second part. Assume the table name as "workforce".
Any help will be highly appreciated.
In the past, I've always generated reports by querying a database, dropping it on a worksheet, sorting, reading into an array, and then looping through to create the documents. What I'm trying to do now is generate the reports directly from the recordset.
The problem I have though is when using arrays I had an absolute record number, so I could check if a field in the previous record was the same as in the current record.
What is the best way of going about doing this with a recordset? Store the field value in a variable? Use nested While loops? Get a total record count and use absolute positions to move back and forth (which doesn't seem like a good idea)?
UPDATE
The recordset contains multiple records from 20 different companies. I sort the query by the company name and then start loop through it. I then need to check each record to see if it's from the same company as the previous and if not create a new worksheet for that company.
I usually do the sort in the query using an "Order By" clause. Then just loop through the sorted records using a variable to track the current sort order name and detect the name change by comparing the current record name field to the variable value.
I made a simple query function as this: =QUERY(range,"select *",1), in my Google Spreadsheet, but the results dose not show any letters, it shows only fields that contains numbers.
Study this link
Syntax
QUERY(data, query, [headers])
data - The range of cells to perform the query on.
Each column of data can only hold boolean, numeric (including
date/time types) or string values.
In case of mixed data types in a single column, the majority data type
determines the data type of the column for query purposes. Minority
data types are considered null values.
Just format your range as a plain text using Format > Number > Plain text option, the below images show how to do it: