/*Built for the Long Haul, operate with Confidence*/
DataFlex applications are designed to stand the test of time, ensuring longevity and reliable performance. With this robust foundation, customer relationships can be cultivated with confidence, while teams operate with peak efficiency.
Try nowDataFlex for you
DataFlex applications stand the test of timecultivate your customer relationships with confidence.
With Studio, Framework, Language, and seamlessly integrated Data, building an application is quick and effortless.
Thanks to the modular, object-oriented language of DataFlex, your team operates efficiently.
The Essence of DataFlex
DataFlex is an all-in-one solution that combines Studio, Framework, Language, and Data, streamlining your development process.
DataFlex Studio is the IDE for DataFlex programming. Streamline your coding experience with an intuitive environment.
The Framework simplifies application design, complemented by an extensive collection of web controls and libraries.
Rooted in an object-oriented approach, DataFlex emphasizes readability, making it a user-friendly language for developers.
Simplify and ensure consistency by setting up data in Business Rules and Data Dictionaries once.
Let the code talk
With DataFlex, less code speaks volumes. Compare yourself...
DataFlex
Use AllWebAppClasses.pkg
Use cPersonDataDictionary.dd
Object oPeople is a cWebView
    Object oPerson_DD is a cPersonDataDictionary
    End_Object
    Set Main_DD to oPerson_DD
    Set Server to oPerson_DD
    Set psCaption to "People"
    Set piMaxWidth to 1024
    Set piColumnCount to 12
    Procedure OnLoad
        Send Clear of oPerson_DD /* Clear the form for input. */
    End_Procedure
    Object oWebMainPanel is a cWebPanel
        Set piColumnCount to 12
        Object oWebGroupPerson is a cWebGroup
            Set piColumnSpan to 6
            Set piColumnCount to 6
            Object oWebFormFirstName is a cWebForm
                Entry_Item Person.firstname
                Set piColumnSpan to 6
                Set psLabel to "First name"
                Set peLabelPosition to lpTop
            End_Object
            
            Object oWebFormLastName is a cWebForm
                Entry_Item Person.lastname
                Set piColumnSpan to 6
                Set psLabel to "Last name"
                Set peLabelPosition to lpTop
            End_Object
            
            Object oWebFormAddress is a cWebForm
                Entry_Item Person.Address
                Set piColumnSpan to 6
                Set psLabel to "Address"
                Set peLabelPosition to lpTop
            End_Object
            
            Object oWebFormPostalCode is a cWebForm
                Entry_Item Person.postalcode
                Set piColumnSpan to 6
                Set psLabel to "Postalcode"
                Set peLabelPosition to lpTop
            End_Object
            
            Object oWebFormCity is a cWebForm
                Entry_Item Person.city
                Set piColumnSpan to 6
                Set psLabel to "City"
                Set peLabelPosition to lpTop
            End_Object
            Object oWebFormCountry is a cWebForm
                Entry_Item Person.country
                Set piColumnSpan to 6
                Set psLabel to "Country"
                Set peLabelPosition to lpTop
            End_Object
            Object oWebButtonSubmit is a cWebButton
                Set piColumnSpan to 2
                Set piColumnIndex to 2
                Set psCaption to "Submit"
            
                Procedure OnClick
                    Boolean bErr
                    Get Request_Validate of oPerson_DD to bErr
                    If (not(bErr)) Begin
                        Send Request_Save of oPerson_DD /* Save the person to the DB if validation was successful. */
                        Send RefreshListFromDD of oWebListPersons /* Refresh the weblist. */
                        Send Clear of oPerson_DD /* Clear the form for input. */
                    End
                End_Procedure
            End_Object
        End_Object
        Object oWebListPersons is a cWebList
            Object oWebColumnFirstName is a cWebColumn
                Entry_Item Person.firstname
                Set psCaption to "First name"
                Set piWidth to 100
            End_Object
            Object oWebColumnLastName is a cWebColumn
                Entry_Item Person.lastname
                Set psCaption to "Last name"
                Set piWidth to 100
            End_Object
            Object oWebColumnAddress is a cWebColumn
                Entry_Item Person.Address
                Set psCaption to "Address"
                Set piWidth to 100
            End_Object
            Object oWebColumnPostalcode is a cWebColumn
                Entry_Item Person.postalcode
                Set psCaption to "Postalcode"
                Set piWidth to 100
            End_Object
            Object oWebColumnCity is a cWebColumn
                Entry_Item Person.city
                Set psCaption to "City"
                Set piWidth to 100
            End_Object
            Object oWebColumnCountry is a cWebColumn
                Entry_Item Person.country
                Set psCaption to "Country"
                Set piWidth to 100
            End_Object
            
        End_Object
    End_Object
End_Object
PHP
// frontend
<h2>Insert a new person</h2>
<form action="submit_person.php" method="post">
    <label for="firstname">First name:</label>
    <input type="text" id="firstname" name="firstname" required><br><br>
    <label for="lastname">Last name:</label>
    <input type="text" id="lastname" name="lastname" required><br><br>
    <label for="address">Address:</label>
    <input type="text" id="address" name="address" required><br><br>
    <label for="postalcode">Postalcode:</label>
    <input type="text" id="postalcode" name="postalcode" required><br><br>
    <label for="city">City:</label>
    <input type="text" id="city" name="city" required><br><br>
    <label for="country">Country:</label>
    <input type="text" id="country" name="country" required><br><br>
    <input type="submit" value="Submit">
</form>
<h2>Saved People</h2>
<?php
// Database configuration
$servername = "localhost";
$username = "root";  // adjust to your database username
$password = "";      // adjust to your database password
$dbname = "phpperson";  // the name of your database
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
// Select all records from the person table
$sql = "SELECT id, firstname, lastname, address, postalcode, city, country FROM persons";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    echo "<table border='1'>
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>Address</th>
                <th>Postal Code</th>
                <th>City</th>
                <th>Country</th>
            </tr>";
    
    // Output data of each row
    $rows = $result->fetch_all(MYSQLI_ASSOC);
    foreach ($rows as $row) {
        $name = sprintf("%s %s", $row['firstname'], $row['lastname']);
        echo "<tr>
                <td>{$row['id']}</td>
                <td>{$name}</td>
                <td>{$row['address']}</td>
                <td>{$row['postalcode']}</td>
                <td>{$row['city']}</td>
                <td>{$row['country']}</td>
              </tr>";
    }
    echo "</table>";
} else {
    echo "No records found.";
}
// Close connection
$conn->close();
?>
// backend
<?php
// Database configuration
$servername = "localhost";
$username = "root";  // adjust to your database username
$password = "";      // adjust to your database password
$dbname = "phpperson";  // the name of your database
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
// Get person details from the form
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$address = $_POST['address'];
$postalcode = $_POST['postalcode'];
$city = $_POST['city'];
$country = $_POST['country'];
// Prepare SQL statement
$sql = "INSERT INTO persons (firstname, lastname, address, postalcode, city, country) VALUES (?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
if ($stmt) {
    // Bind parameters
    $stmt->bind_param("ssssss", $firstname, $lastname, $address, $postalcode, $city, $country);
    // Execute statement
    if ($stmt->execute()) {
        echo "Data successfully saved.";
    } else {
        echo "Error saving data: " . $stmt->error;
    }
    // Close statement
    $stmt->close();
} else {
    echo "Error preparing statement: " . $conn->error;
}
// Close connection
$conn->close();
// Redirect back to the form
header("Location: index.php");
exit;
?>
React
// frontend
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import { Container, Typography, Box, TextField, Button, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, Paper } from '@material-ui/core';
function App() {
  const [nawData, setNawData] = useState([]);
  const [firstname, setFirstname] = useState('');
  const [lastname, setLastname] = useState('');
  const [address, setAddress] = useState('');
  const [postalcode, setPostalcode] = useState('');
  const [city, setCity] = useState('');
  const [country, setCountry] = useState('');
  useEffect(() => {
    axios.get('api/person')
      .then(response => {
        setNawData(response.data);
      })
      .catch(error => {
        console.error('There was an error while trying to get person data:', error);
      });
  }, []);
  const handleSubmit = (e) => {
    e.preventDefault();
    const payload = { firstname, lastname, address, postalcode, city, country };
    axios.post('api/person', payload)
      .then(response => {
        setNawData([...nawData, { id: response.data.id, ...payload }]);
        setFirstname('');
        setLastname('');
        setAddress('');
        setPostalcode('');
        setCity('');
        setCountry('');
      })
      .catch(error => {
        console.error('There was an error trying to save a new person record', error);
      });
  };
  return (
    <Container>
      <Typography variant="h4" gutterBottom>
        Person Details
      </Typography>
      <form onSubmit={handleSubmit}>
        <Box display="flex" flexDirection="row" flexWrap="wrap" mb={2}>
          <Box mr={1}>
            <TextField label="Firstname" value={firstname} onChange={e => setFirstname(e.target.value)} />
          </Box>
          <Box mr={1}>
            <TextField label="Lastname" value={lastname} onChange={e => setLastname(e.target.value)} />
          </Box>
          <Box mr={1}>
            <TextField label="Address" value={address} onChange={e => setAddress(e.target.value)} />
          </Box>
          <Box mr={1}>
            <TextField label="Postalcode" value={postalcode} onChange={e => setPostalcode(e.target.value)} />
          </Box>
          <Box mr={1}>
            <TextField label="City" value={city} onChange={e => setCity(e.target.value)} />
          </Box>
          <Box mr={1}>
            <TextField label="Country" value={country} onChange={e => setCountry(e.target.value)} />
          </Box>
          <Button type="submit" variant="contained" color="primary">
            Save
          </Button>
        </Box>
      </form>
      <TableContainer component={Paper}>
        <Table>
          <TableHead>
            <TableRow>
              <TableCell>Firstname</TableCell>
              <TableCell>Lastname</TableCell>
              <TableCell>Address</TableCell>
              <TableCell>Postalcode</TableCell>
              <TableCell>City</TableCell>
              <TableCell>Country</TableCell>
            </TableRow>
          </TableHead>
          <TableBody>
            {nawData.map(record => (
              <TableRow key={record.id}>
                <TableCell>{record.firstname}</TableCell>
                <TableCell>{record.lastname}</TableCell>
                <TableCell>{record.address}</TableCell>
                <TableCell>{record.postalcode}</TableCell>
                <TableCell>{record.city}</TableCell>
                <TableCell>{record.country}</TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
      </TableContainer>
    </Container>
  );
}
export default App;
// backend
app.get('/api/person', (req, res) => {
  const connection = new Connection(config);
  connection.on('connect', err => {
    if (err) {
      console.error(err);
      res.status(500).send('Database connection failed');
      return;
    }
    const request = new Request('SELECT * FROM Persons', (err, rowCount) => {
      if (err) {
        throw err;
      }
      connection.close();
    });
    let results = []
    request.on('row', (columns) => {
      const record = {};
      columns.forEach(column => {
        record[column.metadata.colName] = column.value;
      });
      results.push(record);
    });
    request.on('doneInProc', (rowCount, more) => {
      console.log(results);
      res.json(results);
      console.log(rowCount + ' rows returned');
    });
    connection.execSql(request);
  });
  connection.connect();
});
app.post('/api/person', (req, res) => {
  const { firstname, lastname, address, postalcode, city, country } = req.body;
  const connection = new Connection(config);
  connection.on('connect', err => {
    if (err) {
      console.error(err);
      res.status(500).send('Database connection failed');
      return;
    }
    const request = new Request(
      `INSERT INTO Persons (firstname, lastname, address, postalcode, city, country)
      OUTPUT INSERTED.id
       VALUES (@firstname, @lastname, @address, @postalcode, @city, @country)`,
      (err, rowCount, rows) => {
        if (err) {
          console.error(err);
          res.status(500).send('Failed to insert data');
        } else {
          res.status(201);
        }
        connection.close();
      }
    );
    request.addParameter('firstname', TYPES.NVarChar, firstname);
    request.addParameter('lastname', TYPES.NVarChar, lastname);
    request.addParameter('address', TYPES.NVarChar, address);
    request.addParameter('postalcode', TYPES.NVarChar, postalcode);
    request.addParameter('city', TYPES.NVarChar, city);
    request.addParameter('country', TYPES.NVarChar, country);
    let results = []
    request.on('row', (columns) => {
      const record = {};
      columns.forEach(column => {
        record[column.metadata.colName] = column.value;
      });
      results.push(record);
    });
    request.on('doneInProc', (rowCount, more) => {
      res.json(results);
    });
    connection.execSql(request);
  });
  connection.connect();
});
How to get started
Why millions use DataFlex
 
          
          
          DataFlex empowers programmers to be more and do more. They are not only coders, they are also business analysts and process architects. They are actively involved in the concepts of analytics and conceptualization. - Christian Hartlieb, CEO, Somentec Software GmbH
 
          
          "Data Access Worldwide helps us to grow new solutions for our customers. In the last few years, that collaboration has expanded to include two major new functionalities" - Bas Mathon, Managing Director, Quantaris
 
          
          We used DataFlex because it enabled rapid development and because the database was reliable. While our competitors kept falling, we just kept evolving maintaining a lead in our niche markets. - Alex Heffer, Product Manager, XLS
FAQ
DataFlex is designed to maximize developer productivity, combining a powerful business logic layer with a flexible front end. Unlike many languages that require extensive boilerplate coding, DataFlex streamlines development, so you can focus on building great applications - fast.
If youve worked with multiple languages, you know the struggle of balancing maintainability, scalability, and speed of development. DataFlex simplifies this equation. Its robust, dynamic, and built for business applications. Plus, it lets you focus on solving problems, not on writing endless lines of repetitive code.
Absolutely! Modern development isnt just about using the latest trendy language - its about efficiency, reliability, and adaptability. With continuous updates, a strong community, and regular releases, were making sure DataFlex stays ahead of the curve.
DataFlex is designed to play well with others! Whether its REST APIs, databases, or third-party services, integrating is straightforward. You get the flexibility to connect with existing systems while keeping development smooth and maintainable.
100%! DataFlex is used in enterprise environments worldwide, handling everything from logistics to financial systems. Its architecture supports scalability, making it easy to grow applications as business needs evolve.
Surprisingly smooth! If youve worked with languages like C#, Python, or JavaScript, youll find the logic familiar. The real magic? Youll be productive faster, thanks to our structured approach and powerful frameworks. And if you ever get stuck, the DataFlex Learning Center has your back.
We always support you
Delve into DataFlex with our Learning Centers video courses-tailored for both beginners and advanced developers. Explore and find answers at your fingertips.
Discovered a bug in DataFlex? Report it in our HelpDesk-built with DataFlex, just like the solutions were crafting. Lets ensure a seamless coding experience together.
Take a detour to the community hub-where DataFlex wizards swap ideas and sprinkle coding magic. Join the lively chatter at the forum!
Explore the DataFlex encyclopedia in our Online Help-packed with product details, control insights, and the latest updates. Discover it yourself!
