Data Envrionments, True DB grids and VB6 - vb6

I have finally been able to get all the columns I wanted to show up in the data environment and have added an additional command to try and pull those values from a local DB into the grid.
The issue I am running into is the values are not appearing inside my grid.
I have it running the correct command to pull in the data I believe: I took that same query and ran it on the local DB and it does output the values I expect. I then clone the Environment command to a record set.
If gbEnableD2D Then
If DataEnvironment7.rscmdMeterReadsDistinctD2D.State <> adStateOpen Then
DataEnvironment7.cmdMeterReadsDistinctD2D
End If
Else
If gbEnableD2D Then
Set rsDevices = DataEnvironment7.rscmdMeterReadsDistinctD2D.Clone
Else
' Display all the columns I want to display
From there I can determine the columns do show up as intended but in the display as well as using the watching system I can not access the MeterReadsDistinctD2D nor does the record set contain the values but does have the fields I expect.
Any thoughts on to why this would occur or how I could go about tracking down how to determine how I can see if these values are in my data environment or if they are in there why they are not being passed to the record set?

You need to make sure the TrueDBGrid is in Bound Mode, then bind it to a Data Control and set the Recordset/Recordsource of the Data Control to your SQL Query. Make sure the ConnectionString of the Data Control successfully connects to your database.

Related

Lazarus DBGrid totally blank after record commit

I have been using Lazarus 2.x (free pascal) with firebird 3 (via flamerobin) and i try to commit records via TSQLConnection, TSQLQuery, TDBConnection in data module (appeals) etc.
I run the following code snippet and the records are successfully commited to firebird, but unfortunately DB connection afterwards is lost and thus there is not any record to be seen via DBGrid (not even column headers - totally blank). I have to terminate the application and reopen it to gain visual insight of my firebird via DBGrid.
Button click event
appeals.SQLTransaction1.Active:=false;
appeals.SQLQuery1.SQL.Text:='UPDATE appeals set name=:name,date_entry=:entry,date_suspended=:suspended,'+
'date_court=:court,date_judgement=:judgement where id='+IntToStr(row_num);
appeals.SQLQuery1.Params.ParamByName('name').AsString:=Trim(Edit1.Text);
appeals.SQLQuery1.Params.ParamByName('entry').AsDate:=DateTimePicker1.Date;
appeals.SQLQuery1.Params.ParamByName('suspended').AsDate:=IncDay(DateTimePicker1.Date,10);
appeals.SQLQuery1.Params.ParamByName('court').AsDate:=DateTimePicker2.Date;
appeals.SQLQuery1.Params.ParamByName('judgement').AsDate:=IncDay(DateTimePicker2.Date,20);
appeals.SQLTransaction1.StartTransaction;
appeals.SQLQuery1.ExecSQL;
appeals.SQLTransaction1.Commit;
I have also used .CommitRetaining as exactly mentioned in lazarus forum without success. Any idea what could i do in order to see my records live in DBGrid after commit.
Regards
The reason the DBgrid shows nothing is that SqlQuery1.ExecSQL does not return a result set, so SqlQuery1 cannot supply any records for the DBGrid to display. So call SqlQuery1.Open after your Commit.
However, before you can call SqlQuery1.Open, you need to give it a SELECT statement to Execute, because a SQL UPDATE statement does not return a result set, as you have already found. So, do something like:
[...]
appeals.SQLTransaction1.StartTransaction;
appeals.SQLQuery1.ExecSQL;
appeals.SQLTransaction1.Commit;
appeals.SQLQuery1.Sql.Text := 'Select * from appeals where ...';
appeals.SQLQuery1.Open;
obviously replacing '...' in the 'where' clause by something appropriate. Normally. a SELECT query should be parameterised to limit the number of rows returned and the amount of time the table is locked on the server.

SQL: Update fields based on another fields information

I am trying to automate an UPDATE query based off one columns data and apply that same field to another.
See screenshot:
In this, what I am trying to do is update PCODE from a value of 0 to that of the value shown in SI_PCODE. This would need to be updated by the unique variable of the SALES_QUOTE_ID. I currently do this manually with excel using
update sales_quote_contact set pcode= where sales_quote_id=;
but want to run this automatically through a batch job I have.

How to get the grid view for query results using oracle sql developer in mac?

When I issue a query like select * from city; using oracle sql developer in mac I get the output that is not aligned and it is very hard to read. How do I get the grid view and set it as default?
Sounds like you're getting the script output. You can have that formatted nicely by using SET SQLFORMAT ansiconsole, we'll make the columns line up as nice as possible based on the size of the display.
But if you want the data back in a grid, use Ctrl+Enter or F9 or the first execute button in the toolbar to execute.
This will get you the output in a grid, like this:
I talk about both executing as a script or statement here.
If your issue is with formatting, you may want to look at this link
If your issue is with records not getting inserted, please note these.
Records inserted in one session will not be visible in another session unless they are committed.
If you are checking the count in the same session where you inserted the records, then check for errors in insert. Add a show errors command at the end of your script, "path_to_file.sql" to check if any errors occurred while inserting the records.
Hope this helps.

Identify if objects are the same

I want to check certain objects against each other and identify if they are the same.
For example, I need to verify that the total cost in one page is the same as another page. I developed a script that works, however the total cost changes every day so I have to update the object properties in maintenance mode every day.
Is there a way that UFT automatically recognizes this object must change and update?
I request you to elaborate your question. For now, you can use .* if certain values of the object are changing. Alternatively, you can store the values in an excel sheet and you can change everyday depending on the requirement.
If this is not helpful let me know
It sounds like you actually want to compare the values shown in two different objects, and see if those values are the same. (I assume this because you say they are on two different pages)
Also, you mention maintenance mode, so I assume you are using checkpoints to store their expected values.
I would suggest: instead of storing the expected values in a checkpoint, you could read the value of the first object (getROproperty), store it in a variable (dataTable field, environment variable, etc), and then navigate to the other page, read the ROproperty from the other object, and then compare.
i.e.
if {browser,page,object...}.getROproperty({whateverPropertyYouNeed}) = environment({storedFirstValue}) then
reporter.reportevent micPass,"compare step","{details here}"
end if
*replace stuff inside {} with your code, I don't know what it is
If you need to actually store the total cost externally, you could use a DataTable field and export the sheets at the end. then import the same sheet at the beginning. That would save the data to an excel sheet on a drive.

Using variables in From part of a task flow source

Is there any way to use a variable in the from part (for example SELECT myColumn1 FROM ?) in a task flow - source without having to give the variable a valid default value first?
To be more exact in my situation it is so that I'm getting the tablenames out of a table and then use a control workflow to foreach over the list of tablenames and then call a workflow from within that then gets data from these tables each. In this workflow I have the before mentioned SELECT statement.
To get it to work properly I had to set the variable to a valid default value (on package level) as else I could not create the workflow itself (as the datasource couldn't be created as the select was invalid without the default value).
So my question here is: Is there any workaround possible in this case where I don't need a valid default value for the variable?
The datatables:
The different tables which are selected in the dataflow have the exact same tables in terms of columns (thus which columns, naming of columns and datatypes of columns). Only the data inside of them is different (thus its data for customer A, customer B,....).
You're in luck as this is a trivial thing to implement with SSIS.
The base problem for most people is that they come at SSIS like it's still DTS where you could do whatever you want inside a data flow. They threw out the extreme flexibility with DTS in favor of raw processing performance.
You cannot parameterize the table in a SQL statement. It's simply not allowed.
Instead, the approach that people take is to use Expressions. In your case, assuming you had two Variables of type String created, #[User::QualifiedTableName] and #[User::QuerySource]
Assume that [dbo].[spt_values] is assigned to QualifiedTableName. As you loop through the table names, you will assign the value into this variable.
The "trick" is to apply an expression to the #[User::QuerySource]. Make the expression
"SELECT T.* FROM " + #[User::QualifiedTableName] + " AS T;"
This allows you to change out your table name whenever the value of the other variable changes.
In your data flow, you will change your OLE DB Source to be driven by a query contained in a variable instead of the traditional table selection.
If you want an example of where I use QuerySource to drive a data flow, there's an example on mixing an integer and string in an ssis derived column
Create a second variable. Set its Expression to create the full
Select statement, using the value of the first variable.
In the Data Source, use "SQL command from variable" option for the
Data Access Mode property.
If you can, set a default value for the variable you created in step
That will make filling out the columns from your data source much easier.
If you can't use a default value for the variable, set the Data
Source's ValidateExternalMetadata property to False.
You may have to open the data source with the Advanced Editor and
create Output columns manually.

Resources