Devexpress, Can't Insert a new row if the database is empty - insert

As the title describes, I have a table in my database, my BootstrapGridView displays a cannot insert new record because some field doesn't allow Null (Despite its not NULL), the weird thing is that if I add a record manually directly in the database, I become able to add new records normally from the BootstrabGridView, so, help me out please.
I cleared the database table, so, if it's empty I cannot add new records to it.
I added the record from SSMS normally, of course with respect to the Foreign keys and all, and it's added well, then I tried adding from the Gridview again and it's working.
I cleared the table again, and it doesn't work again

Related

Populate data from DB and save as new record oracle forms

I Have populated master detail block from Data based want to change some values in data block and save it as a new record in Both master and child tables.
To Populate used execute query
Changed values as record
Save by commit
But as i used execute query to populate existing data on commit it is trying to update already saved data in table. But i want to create new records in DB with new primary key
That won't work, as you noticed. Records you fetched are database records so - once you update their values and commit, you overwrite data.
If you want to insert new records, then
add them into new rows - you can do that manually (by typing those values), or
you can duplicate one of previous records into a new record (use Forms menu for that or a shortcut key; look for "duplicate record" option) and modify that duplicated record.
Alternatively, don't use data block but control block (the one that isn't based on a database table). Populate it, somehow (e.g. you could create a button which calls the procedure; it uses a loop and populates record-by-record). Modify values you want and create your own procedure which will insert new rows into the database table. As of the primary key, it depends on how you do it; if it is a database trigger which uses a sequence, it (the trigger) will do the job. Otherwise, you'll have to create a primary key yourself (during the insert process).

Identify a new inserted record from a record obtained by query

How can I identify in oracle forms the difference between a record obtained from the database and one just newly inserted ?
I need to requery after a button click if the record is queried before and if it is a newly inserted record then I only need to query the new record, because a requery won't contain the new record or if no query happened before then a requery will do a full query.
I tried with :system.record_status, but after commit it also contains QUERY
Exactly; after commit & requery, all records are equal and their status is QUERY.
I don't think you can do that, unless you mark newly added rows, somehow (e.g. by adding a timestamp so all rows with the MAX(timestamp) value are considered to be new).

INSERT new row or DELETE old row IF it already exists using laravel

I am assigning multiple skills to an employee using checkboxes. when a user checks the checkbox a new record is inserted into pivot table. if a user unchecks the checkbox a record is deleted.
Now i am wondering if there is any function for insert or delete like there exists for new insert or update which is updateOrCreate to update an existing record or create a new record if none exists.
I can do it the hard way. but just want to know if there is any function for this like updateOrCreate.
Use the sync method it will replace the old values to new.
$employee->skill()->sync($request->checkedSkill)

prevent last record in access table to be deleted

I made a loginform for my access database but how to prevent anyuser to delete the last record
Ex: if there is two records in login_table or more. The user can delete all the record but not the lastone
There are many ways to do that:
1. Create constraint on your server side code to check whether there is only one record at the time of deleting the records.
2. Create a trigger on the table which prevents the user from deleting the last record.
Probably the easiest way to accomplish this in Access 2013 would be to create a "Before Delete" data macro that looks like this:
If DCount("*","Table1")<2 Then
RaiseError
Error Number 1
Error Description You cannot delete the last remaining record in this table.
End If
To create this data macro, open the table in Design View, then on the "Design" tab of the ribbon click "Create Data Macros" and choose "Before Delete". (Remember to replace "Table1" with the actual name of your table.)
The previous record is saved in the table so it can be deleted. The record being entered is not actually saved in the table until the form is closed or an action is taken to enter another record.
On an entry form I create a duplicate table with the same fields. The entry form places the data temporarily into the first table. Then I created two queries. One to update from the temporary table to the secondary table. The second query clears the first table making it ready for new data entry. The action of the query requires to command entry to save the record prior to running the two queries. I perform this by creating a macro to perform the actions in sequence. 1. save record, 2 copy the data to the second table, 3 clear the first table.
You will have better control over the data.

Maximum number of columns in a LINQ to SQL object?

I have 62 columns in a table under SQL 2005 and LINQ to SQL doesn't handle the updates though the reading would work just fine, I tried re-adding the table to the model, created a new data model but nothing worked, I'm guessing I've hit the maximum number of columns limit on an object, can anyone explain that ?
I suspect there is some issue with an identity or timestamp column (something autogenerated on the SQL server). Make sure that any column that is autogenerated is marked that way in the model. You might also want to look at how it is handling concurrency. If you have triggers that update any values on the row after it is updated (changing values) and it is checking all columns on updates, this would cause the update to fail. Typically I create my tables with a timestamp column -- LINQ2SQL picks this up when I generate the model and uses it alone for concurrency.
Solved, either one of the following two
-I'm using a UniqueIdentifier column that was not set as Primary key
-Set Unique ID primary key, checked the properties of the same column in Server Explorer and it was still not showing as Primary key, refreshed the connection,dropped the same table on the model and voila.
So I assume I made a change to my model some time before, deleted the table from the model and added the same from the Server explorer without refreshing the connection and it never used to work.
Question is, does VS Server Explorer maintain it's own table schema and requires connection refresh everytime a change is made in the database ?
There is no limit to the number of columns LINQ to SQL will handle.
Have you got other tables updating successfully?
What else is different about how you are accessing the table content?

Resources