
PRO
rz90208
USA
Asked
— Edited

I have went thru the tutorial for the plugin and have successfully created a basic plugin. Now I want to go the next step and create a plugin that has a configuration page that is accessed by clicking the gear icon but can not figure out how to do it.
The plugin I hope to create will allow the user to create a connection to a database using a DSN.
RichardZ
Update:
One Step Closer -
I found the UCConfigurationButton
Update2:
Stumbled upon ptp's testplugin on github and creating a ConfigForm.cs using it as my example.
Ok my friend where did I go wrong. (besides trying this in the first place)
Here is my code. When I debug from VisualStudio, I get unknown function.
I did add my plugin to my project and see the blank form.
I get no errors when I build the project.
Code:
Select the form main. In the event Browser select those events to assign to those methods.
I see FormMain_Load and FormMain_FormClosing but do not understand what you want me to do with them.
Sorry this C# is all new to me yet.
you are progressing in the right direction, almost there.
Opening Visual Studio, I'll code the missing logic, give me a couple minutes.
I added a new function QueryData to the Miscellaneous Utility Plugin:
https://synthiam.com/redirect/legacy?table=plugin&id=293
Source Code:
https://github.com/ppedro74/ezrobot-playground/blob/master/plugins/MiscUtilityPlugin/MiscUtilityPlugin/MainForm.cs
I'm running out time, so minimal documentation, and basic tests no bullet proof code.
**Copied from the plugin page***
version 4 :
Added: DataQuery function
Syntax: DataQuery (connection, query, [limit], [output variable], [query argument 0], [query argument 1], [query argument n]) => Int32
Connection: Provider Name and connection string.
Query: SQL Query
Limit: Max Number of records to return. Default 100
Output Variable: Name of Array Variable. Default is $data_ . $data_0 array for column 0 values, $data_1 array for column 1 values, etc.
Query Argument 0: Value for query Parameter @0, @1, etc.
Returns: Number Of Rows
Some Examples:
Excel File (Note Excel 97/2003 format)
Excel1.zip
SQL 2012 server Query:
Code:
ODBC User DSN MyDSN1 Query :
Code:
ODBC excel 97/2003 Query:
Code:
OLEDB excel 97/2003 Query:
Paging the results, using a query parameter @0 for $LastId
Code:
Try it and let me know the feedback.
As for learning events, google tutorials are great. If you look at the code which you’ve copy and pasted from my tutorial, there’s a formmain_load and formmain_closing
Those aren’t being executed because they’re not connected to anything. Events in object oriented programming are executed when something else executed them. In those case, by their names, loading the form and closing the form.
You need to tell the form to execute those functions when the form loads and when the form is closing.
Do that in the events list of the properties of the form. Locate the form loading and form closing options and select the appropriate methods from the drop down.
Look at this video. It’s terriblr quality but he shows exactly how to find the events for a form: https://youtu.be/LbgO1lZ6WRI
All graphic objects have events. You can explore what events each object has. For example a button has an OnClick event for when it’s pressed
Thank you DJ that now makes sense. I will look when I get home this evening.
@ptp,
Thank you so much. I will study the code and add to my plugin project as a learning experience.
I will post how it all goes on Thursday after the site comes back up.
RichardZ
I tried your plugin and all I can get is the number of hits the query received not the actual data.
Code:
The function returns the number rows.
Your data is in the array variable $data_0
Add the variable monitor control and you will see the data there.
Thank you
I looked at all examples but that one was using a different data provider so I just looked over that.
This is great ptp, thank you so much.
when I complete the database brain I owe you a copy.
RichardZ
When trying to insert a record using
$sql = "INSERT INTO MemAtom (MemType, MemData) VALUES (7, '" + $varSTR1 + "')"
$varSTR1 equals one of the 2 lines.
The first line inserts correctly, the second gives me an error Syntax error (missing operator).
1) All the men of thy confederacy have brought thee even to the border: the men that were at peace with thee have deceived thee, and prevailed against thee, that they eat thy bread have laid a wound under thee: there is none understanding in him.
2) All the Nethinims, and the children of Solomon's servants, were three hundred ninety and two.
I wrote a VBScript to do the same thing and get the same result that tells me it is not a bug but something
with my insert statement but I can not figure it out.
I can paste the line into the database just fine.
Any guess as to what my issue is? with the insert statement I mean.
RichardZ
SQL Strings use single quotes. If your $varSTR1 contains a single quote will break the query.
That is the reason why I've implemented parameterized queries, at least for strings and numbers it will work (ez-script supported types).
using a parameterized query parameter @0:
Code:
PS: The forum is still in beta mode and is crippled i know the things will be fixed soon or later, for faster responses drop me an email : tiago.private AT gmail.com.
@ptp
That worked.
I edited my source document and changed all ' to nothing
saved the doc and all imported without error.
Not the best solution but will work. I don't think the robot will speak the word any different
Servent's or Servents
Thank you again
is this addon still working?
I get an error when trying to use in.
Code:
Start
> Error on line 3: Unknown function: DataQuery.
Done (00:00:00.0048909)
you can download the plugin:
be5678f2-3db9-4c29-9aad-5d0f67227b9e.ezplugin.zip
remove ".zip" extension and then double click to install.
Now if I can only remember how to phrase the Select statement correctly for MS Access.
RichardZ
So if my query returns less data then the previous query I have garbage left in the array.
doing a ClearVariables() before each query would work if I didn't mind losing all my other variable data, which is not an option.
My current workaround is to always look at the reported Array size and just ignore the garbage data.