Create a sql table

Create a sql table

herculeshercules Posts: 21Questions: 9Answers: 0
edited May 2017 in Free community support

What code would I use to create an SQL table that would interface with the code generated by the datable editor code generator. I think it created code to crate a Mysql table.

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    The Editor generator page offers "SQL server" database type.
    https://editor.datatables.net/generator/index

  • herculeshercules Posts: 21Questions: 9Answers: 0

    Yes, but it doesn't work. The create Table code does not work

  • kthorngrenkthorngren Posts: 21,591Questions: 26Answers: 5,004

    Did you configure the DB connection info?

    The create Table code does not work

    Do you get an error when the table creation fails?

    Have you tried copying the generated table creation code into the SQL query tool of the application you use to manage MySql?

    Kevin

  • herculeshercules Posts: 21Questions: 9Answers: 0
    edited May 2017

    I don't have an application to manage MySql. I just read somewhere that that error is caused by the generator code for MySQL. Yes I did enter my database type (sqlserver) and connection string in the settings.settings file. Everything works except for that piece of code that creates the table if it doesn't exist. Is this web api used in a production environment or primarily just for testing? Because for a beginner it structures my solution in a way that for me makes it hard to edit anything. I am watching a youtube video that will give me the same functionality without creating a structure that I am not familiar with. Why does it not create the begin form code? Also it doesn't automatically create the dropdownlist with the number of records you want to show. And I want my edit and delete as buttons inline and it doesn't seem straightforward how to do. Thanks for your help.

  • allanallan Posts: 63,889Questions: 1Answers: 10,530 Site admin
    Answer ✓

    I've just tried Generator with the configuration shown in the attached screenshot. It creates SQL Server code:

    IF object_id('id', 'U') is null
        CREATE TABLE id (
            [id] int not null identity,
            [a] varchar(255),
            [s] varchar(255),
            [c] varchar(255),
            PRIMARY KEY( [id] )
        );
    

    Perhaps you can show me how you have configured Generator so I can attempt to recreate the issue?

    Because for a beginner it structures my solution in a way that for me makes it hard to edit anything.

    If the program structure that Generator makes doesn't suit your needs, don't use it. Generator is only designed as a quick start tool for those who aren't familiar with .NET or Javascript.

    Why does it not create the begin form code?

    What begin form code? Generator creates the Javascript needed for the Editor form.

    Also it doesn't automatically create the dropdownlist with the number of records you want to show.

    See the Q. How can I show the page length select when using Buttons?.

    And I want my edit and delete as buttons inline and it doesn't seem straightforward how to do.

    Like in this example? Generator isn't design to give you all of these options. To get the most out of the software, like any software library, you have to use its API and options. Generator is a quick start tool only.

    Allan

This discussion has been closed.