
SQL-Tools is the foundation for FormKit-Tools and HTML-Tools. If you are using a SQL database, your forms start here.
Using this SQL-first design, create your table with a class in mind. Copy the create statement for this table and convert it to csv list. This csv list can then be used to generate FormKit and HTML markup in FormKit-Tools and HTML tools.
Sample data format:
SQL Create Statement
CustId INT DEFAULT NULL,
cust_common VARCHAR(55) DEFAULT NULL,
NAME VARCHAR(45) DEFAULT NULL,
OWNER VARCHAR(45) DEFAULT NULL,
CONTACT VARCHAR(45) DEFAULT NULL,
ADDRESS1 VARCHAR(45) DEFAULT NULL,
ADDRESS2 VARCHAR(45) DEFAULT NULL,
CITY VARCHAR(45) DEFAULT NULL,
STATE VARCHAR(45) DEFAULT NULL,
Zip VARCHAR(45) DEFAULT NULL,
PHONE1 VARCHAR(45) DEFAULT NULL,
PHONE2 VARCHAR(45) DEFAULT NULL,
DIRECTIONS VARCHAR(200) DEFAULT NULL,
GATE VARCHAR(45) DEFAULT NULL,
DOOR VARCHAR(45) DEFAULT NULL,
Copy/paste the create statement into the box and click "Go".
To force all data types to string, check the "All Data Types To String" checkbox before clicking "Go."
When copy/pasting the SQL create statement, don't be overly concerned with unwanted fields. The create statements generate a checkbox list, which allows the fields to easily be narrowed down.
SQL-Tools options.
The options are fairly straight forward. It might be noted that multiple checkboxes may be selected here. Selecting multiple checkboxes may have unintended consequences. It may take a few tries to get the desired results.
The table and table alias fields allow the creation of the SQL DLM statements with the actual table names and alias.
Note: Output may need to be generated several times for SQL statements. An alias may be desired for the select statement, but not the update statements (uncommon). It just takes a second to generate the statements either way. The alias is omitted on insert statements.
The following is an example of the actual results generated from our SQL create statement.
SQL DLM Statements
SELECT c.Name, c.Owner, c.Contact, c.Address1, c.Address2, c.City, c.State FROM Customers c
INSERT INTO Customers (Name, Owner, Contact, Address1, Address2, City, State) values(@Name, @Owner, @Contact, @Address1, @Address2, @City, @State)
UPDATE Customers c SET c.Name = @Name, c.Owner = @Owner, c.Contact = @Contact, c.Address1 = @Address1, c.Address2 = @Address2, c.City = @City, c.State = @State
Javascript Objects
const dataObj = {
Name: "Name",
Owner: "Owner",
Contact: "Contact",
Address1: "Address1",
Address2: "Address2",
City: "City",
State: "State"
};
C# Class Files
public class ClassName
{
public string Name { get; set; }
public string Owner { get; set; }
public string Contact { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string State { get; set; }
}
Comma Separated Values
Name, Owner, Contact, Address1, Address2, City, State
This was incredibly fast and easy to generate. Yes, there are frameworks that automatically generate code. They add a lot of complexity to a project. SQL-Tools is a quick and easy way to quickly generate some common boilerplate code.
To generate forms for the above data, it is now as simple as copy/pasting the csv list above into FormKit-Tools (or HTML-Tools).
Note: Obviously the SQL DLM statements are basic. Table joins will require a little extra work and copy/pasting.
Note: The Javascript objects may need a little editing. If you have a date picker, just throwing the string "Date" into it isn't going to work.
Known Issues:
- SQL column names with spaces in them. Don't see these a lot, but they exist.
- SQL column names with ")" or "," in it. Parenthesis and single comma are reserved words, but they can be used.