I have a datagridview that i fill and after i click on a button and all the rows goes to my database, that is working, but when i want to insert more rows and insert into the database it insert all the rows again and i just want the last ones added.
If anyone could help me i appreciate.
Can't comment so I will write here...
So if I do understand you correctly you are filling gridview sending it to database. After that you fill once more the gridview and send it but this time it also send the one already are on the gridview?
Edit/Update (after the extra info [see below comments])
You can use the SELECT statment to put only values that does not exist.
Before you start using this method/statment you need to know very well which values can be put multiple times so you will write your WHERE statment that way...
I did make a example for you check it out:
Example on DBFIDDLE
There are also another option of you doing this and it is using the IF statment. I will also make a SQLFIDDLE of this but first I need to go to the market and will edit this post with that too once I come home.
Related
please read my question to end because I test all previous solutions in Stackoverflow and have no answer.
I am trying to display Combobox in the form of an MS Access database using VBA, this Combobox takes its values from one table the problem that I can't display just unique values, Combobox views all values even when I use DISTINCT still view all.
also, I am trying to use GROUP BY but not work.
I know it is a simple problem but how can I solve it?
SELECT DISTINCT Exports_imports_Table.ID, Exports_imports_Table.content FROM Exports_imports_Table;
Assuming the ID field is a unique value (and the content field may have duplicates) you cannot include it in a DISTINCT. Try it like this
SELECT DISTINCT Exports_imports_Table.content FROM Exports_imports_Table;
Does that give you what you expect?
Don't take the ID field in your query builder. Instead of that, select the same field twice, leaving one of them as is, and in another you can give your conditions or formats (if any).
Make sure to change unique values in general properties to "yes".
Save it, and there you are.
I have a query that will be populating a form and then the form will allow the data set to be edited. The issue I am having is that the query is pulling the last row that is normally used to add a new record. This results in having a row that looks shows all fields as blank, but leaves one field with "null".
I played around with the query and was able to find a workaround by selecting "distinct" records, problem is that when you select with distinct, you cannot edit the data set. Is there any other way around this?
I can upload an example of the database if needed.
Thanks!
edit: picture to show the issue: https://imgbomb.com/i/?rO1sp
I wish to develope an asp page using vb.net, using which one can insert more than one records
at a time for example "Item Order Placing form" in which one can place more than one order and can see its whole order also so how can it be possible using gridview with vb.net ?
You should really try first... and then post code you have a problem with. One possible solution would be to have a listview or gridview and an area below where the person enters each order item one at a time. When order complete click button. This fill fire code which you need to write that will go through each row and add to db.
I'm having an issue with using a datagridview for a user entering data that's saved to a database. Basically, I just want them to throw stuff into a row and then my code will insert the data.
I tried LeavingRow event, but the problem with this is,enter the values in default row that is already added in datagridview, these value hasn't updated when this event triggers.
I also tried UserAddsRow, but had that fail because it triggers as soon as the user starts typing to add a row.
In Row leave event Use the following code before savig. Then try to save. While saving also you see the index of the row which your code is pointing.
yourgrid.CommitEdit(DataGridViewDataErrorContexts.Commit);
This code may help you..
I'm trying to create a form that allows my audit team to help identify transactions that need further investigation.
Is the following is possible? If so what would be the best method for accomplishing this? I would like to have a check box in a form for each record that is returned from a query. That check box would then be used to identify records that would be appended to another table.
I've done this in the past for forms linked to temporary tables; however, since this form is linked to a query I think I'm having an issue.
You could add the checkbox to the form and use some VBA code to insert all those rows from the query into another table that have the checkbox checked (Forms!MyForm!myCb = True)