File Query |
Scroll |
Some category fields may have custom types which are defined in foreign data base table. A File Query allows you to retrieve this data base table, given the field number of a field with the corresponding custom type.
1 |
Connect to the Thereforeā¢ server (see "Server - Connect and Disconnect" for Details) |
2 |
Declare and initialize a new TheQuery. |
3 |
Set a Category and Load it from the server (Comparable to SQL's FROM clause). |
4 |
Select the fields (columns) to be included in the results (Comparable to SQL's SELECT clause). |
5 |
Specify conditions for your query (Comparable to SQL's WHERE clause) |
6 |
|
7 |
7A. Set the FileByFieldNo property to the number of a field of a type defined in a foreign table. or 7B. Set the FileByColName property to the column name of a field of a type defined in a foreign table. |
8 |
Execute the query on the server. |
9 |
Optional. Display the query results in a MessageBox. |
Requirements and Assumptions: Category number 8 with a string named "UserID" and field number 98 of a type defined in a foreign table. If these assumptions do not apply to your system or configuration please replace them with appropriate values when copying the code samples below. Visual Basic Imports Therefore.API '...
' 1. Connect to the Thereforeā¢ server Dim server As New TheServer server.Connect(TheClientType.CustomApplication)
' 2. Create a new Thereforeā¢ query Dim fileQuery As New TheQuery
' 3. Load a category fileQuery.Category.Load(8, server)
' 4. Select which fields to include in the results fileQuery.SelectFields.AddAll()
' 5. Specify conditions fileQuery.Conditions.Add("UserId", ">1")
' 6. Set the Mode to FileQuery fileQuery.Mode = TheQueryMode.FileQuery
' 7A. Set the FileByFieldNo property. fileQuery.FileByFieldNo = 98
' 7B. Set the FileByColName property. ' fileQuery.FileByColName = "UserId"
' 8. Execute the query on the server Dim fileResults As TheQueryResult = fileQuery.Execute(server)
' Optional 9. Display the results in a MessageBox. System.Windows.Forms.MessageBox.Show(fileResults.ToString()) C# using Therefore.API; //...
// 1. Connect to the Thereforeā¢ server TheServer server = new TheServer(); server.Connect(TheClientType.CustomApplication);
// 2. Create a new Thereforeā¢ query TheQuery fileQuery = new TheQuery();
// 3. Load a category fileQuery.Category.Load(8, server);
// 4. Select which fields to include in the results fileQuery.SelectFields.AddAll();
// 5. Specify conditions fileQuery.Conditions.Add("UserId", ">1");
// 6. Set the Mode to FileQuery fileQuery.Mode = TheQueryMode.FileQuery;
// 7A. Set the FileByFieldNo property. fileQuery.FileByFieldNo = 98;
// 7B. Set the FileByColName property. // fileQuery.FileByColName = "UserId";
// 8. Execute the query on the server TheQueryResult fileResults = fileQuery.Execute(server);
// Optional 9. Display the results in a MessageBox. System.Windows.Forms.MessageBox.Show(fileResults.ToString()); |