FillBy always fills in the same row in data grid view. How to make it fill in a new row for each click of the Fillby Button? VB 2010 EXPRESS?

Hi there, 
I am a beginner in Visual Basic Express 2010. I have a Point of Sale program that uses DataGridView to display records from an external microsoft access
database using the fillby query. 
It works, but it repopulates the same row each time, but i want to be able to display multiple records at the same time, a new row should be filled for
each click of the fillby button. 
also I want to be able to delete any records if the customer suddenly decides to not buy an item after it has already been entered. 
so actually 2 questions here: 
1. how to populate a new row for each click of the fillby button 
2. how to delete records from data grid view after an item has been entered 
Thanks 
Vishwas

Hello,
The FillBy method loads data according to what the results are from the SELECT statement, so if there is one row then you get one row in the DataGridView, have two rows then two rows show up.
Some examples
Form load populates our dataset with all data as it was defined with a plain SELECT statement. Button1 loads via a query I created after the fact to filter on a column, the next button adds a new row to the existing data. When adding a new row it is appended
to the current data displayed and the primary key is a negative value but the new key is shown after pressing the save button on the BindingNavigator or there are other ways to get the new key by manually adding the row to the backend table bypassing the Adapter.
The following article with code shows this but does not address adapters.
Conceptually speaking the code in the second code block shows how to get the new key
Public Class Form1
Private Sub StudentsBindingNavigatorSaveItem_Click(
sender As Object, e As EventArgs) Handles StudentsBindingNavigatorSaveItem.Click
Me.Validate()
Me.StudentsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MyDataSet.Students' table. You can move, or remove it, as needed.
Me.StudentsTableAdapter.Fill(Me.MyDataSet.Students)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.StudentsTableAdapter.FillBy(Me.MyDataSet.Students, ComboBox1.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.MyDataSet.Students.AddStudentsRow("Jane", "Adams", "Female")
End Sub
End Class
Get new key taken from
this article.
Public Function AddNewRow(ByVal sender As Customer, ByRef Identfier As Integer) As Boolean
Dim Success As Boolean = True
Try
Using cn As New OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
cmd.CommandText = InsertStatement
cmd.Parameters.AddWithValue("@CompanyName", sender.CompanyName)
cmd.Parameters.AddWithValue("@ContactName", sender.ContactName)
cmd.Parameters.AddWithValue("@ContactTitle", sender.ContactTitle)
cn.Open()
cmd.ExecuteNonQuery()
cmd.CommandText = "Select @@Identity"
Identfier = CInt(cmd.ExecuteScalar)
End Using
End Using
Catch ex As Exception
Success = False
End Try
Return Success
End Function
In closing I have not given you a solution but hopefully given you some stuff/logic to assist with this issue, if not perhaps I missed what you want conceptually speaking.
Additional resources
http://msdn.microsoft.com/en-us/library/fxsa23t6.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

Similar Messages

  • I backed up two Iphones to the cloud and accidentally chose merge. How can I reset it to have seperate backups for each phone with the same ITUNES login?

    I backed up two Iphones to the cloud and accidentally chose yes to merge the contacts from the two phones. How can I reset it to have seperate backups for each phone even though I am using the ITUNES login?

    i merged two phones contracts are together how to get back to seperate

  • HT201493 How can I add my daughter to Find my friends when we have the same itunes account and that's how they make us log in?

    How can I add my daughter to Find my friends when we have the same itunes account and that's how they make us log in?

    1) You asked "Does she need to reconnect to that itunes/computer and if so what do we need to do to remove this folder of pics from her ipod?" Yes, you have to connect the iPod to that computer and go to the Photos pane for the iPod in iTunes and uncheck sync photos and the click on synce/apply. In the future do not check sync photos.
    iOS and iPod: Syncing photos using iTunes
    2)
    Create a NEW account for using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before.
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    Then on the iPod go to
    - Settings>Messages>Send and receive and sign out your ID and sign into hers. Make sure that only her ID email address is listed.
    - Settings>FaceTime sign out of your ID and sign into hers. Make sure that under You can be reached at only her ID email address is listed
    - Settings>iCloud and sign out and sign in with hers
    Contnue to use the commpn ID/account for Settings>iTunes and App stores.

  • Can I use more than one blue-tooth device at the same time on IPhone 4S? Like a wireless headsets and speed and cadence sensor for cycling computer, receive the data and listen music simultaneously

    Can I use more than one blue-tooth device at the same time on IPhone 4S? Like a wireless headsets and speed and cadence sensor for cycling computer, receive the data and listen music simultaneously

    As long as the profiles are different (ex. HID vs AD2P) you will not have any issues. But say if you try to use 2 keyboards at once, it won't work. Or 2 headsets at once. Your scenario seems fine.

  • HT3819 Home Share issue: I have a Mac and Apple TV. Both are log into the same Wifi network and the same iTunes account (I can view purchased movies on AppleTV). Home Sharing shows 'ON' for both devices. BUT...AppleTV shows no computers. Itunes sidebar-no

    Has anyone else found solution to Apple devices not 'seeing' each other on Home Share?  I have a Macbook Air (new Nov'12) and Apple TV (new Dec'12). Software updated on both. Both are logged into the same Wifi network and the same iTunes account (I can view movies purchased from iTunes on my AppleTV). Home Sharing shows 'ON' for both devices. BUT...AppleTV shows no computers... and ... Itunes sidebar does not have a 'Shared' area at all.  Help please as without this functionality, my Apple TV only provides portal to purchased (i.e. Netflix,...) content which I can get from Wii or Xbox.
    I have already tried the following without success:
    1. Homeshare DID work the first day after I setup Apple TV... but the next day it has not worked since then.
    2. Powered off 30 sec then re-started (Apple TV & Macbook & iTunes login)
    3. Checked Firewall settings per Home Sharing troubleshooting guide (correct settings)
    4. Turning on Photostream in iPhoto and selecting iPhoto within iTunes and then checking to see if Photostream shows anything on AppleTV (it shows 'on' for my iTunes account but 'Zero' pictures found ... despite the >3,000 pictures showing avail in iTunes).
    I also have 'Remote" app on my iPhone 4, with Home Sharing turned on (same Wifi network)... it has a very similar message as the Apple TV and same result that despite all devices having HomeShare 'on' they cannot see each other:  "Remote will automatically find the iTunes libraries and Apple TVs that have Home Sharing turned on using the account xxxx (it lists my correct itunes account name)."

    I solved this by reset of the Wifi (unplug cable and power to both modem and wifi ... wait 60 sec ... plug in modem cable and power ... plug in wifi power and LAN to modem ... restart AppleTV and Mac ... Turn Home Share 'OFF' in iTunes then back "ON" ... it took ~60 sec for the AppleTV to pick up my Mac in computers.

  • HT204053 My wife and I shared the same AppleID but want to break these apart. We set up a new AppleID for her but can't get this changed on the phone. How do we switch her AppleID default on her iphone 4?

    My wife and I shared the same AppleID but now want to break these apart into separate accounts. I have set up a new appleid for her and also set up on line. However, I can't figure out how to change this on her iphone4. I have looked at all of the General settings but need guidance. When I use the phone to try to purchase songs from itunes, it reverts to the old appleID. 
    Any suggestions?

    Welcome to the Apple Community.
    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")
    Providing you are simply updating your existing details and not changing to another account, when you delete your account, all the data that is synced with iCloud will also be deleted from the device (but not from iCloud), but will be synced back to your device when you login again.
    In order to change your Apple ID or password for your iCloud account on your computer, you need to sign out of the account from your computer first, then sign back in using your updated details. (System Preferences > iCloud, click the sign out button)
    In order to change your Apple ID or password for your iTunes account on your iOS device, you need to sign out from your iOS device first, then sign back in using your updated details. (Settings > store, scroll down and tap your ID)

  • How do I sync apps from the same iTunes account to an iPhone 3G and an iPhone 4S and keep correct version for each iOS?

    I have an old 3G as well as a 4S. Initially I set up a separate iTunes account for the 4S as I was worried I'd lose my old apps for 3G (as older, compatible versions aren't kept in the iTunes store so once they're gone, they're gone...). 3G is set up to sync with iTunes, 4S is inly syncing mail and conatcts through Exchange but hasn't been synced with an iTunes library for the reason above.
    Is there a way to sync both phones off the same iTunes account, so I can set up each phone with some music, as well as apps, without iOS 5 versions overwriting the exisitng apps for the 3G?
    To complicate things further, I don't want to sync photos, contacts, messages, etc. I just want to avoid having to duplicate all my music and pay for all the apps all over again. Suggestions?
    Cheers

    Hi gail,
    Thanks for the quick reply! The music part makes sense, good to know I don't have to duplicate the lot. The big question stillr emains as to whether iTunes can cope with two different iPhones, running different versions of the iOS, and therefore different app versions.
    Currently all the apps in iTunes are years old, and many haven't updated in months (years?) because the 3G is running iOS 4.2.1 (and can't be upgraded). Many of these have since been updated in the iTunes store (for the various incarnations of iPhone since) and the old versions that my 3G requires have been replaced.
    I'm worried that syncing the 4S running iOS 5, and running the most recent updates for same apps, will cause iTunes to overwrite the old 3G compatible ones when I sync. Unless iTunes is smart enough to know which version of the app is for which OS, without updating the legacy version when I update the apps on the 4S?
    You guys shouldn't face that problem, as iPad and iPhone apps don't replace each other (I believe? Not sure about this) as new updates are released for each app, you'd have a copy for each device (for example Evernote for iPad, and Evernote for iPhone). I can't figure out if iTunes can handle keeping separate iPhone versions for Evernote iOS 4.2.1 and Evernote for iOS 5. My gut feeling is no, but I want to amke sure before I lose the legacy versions of each app.
    Of course, maybe I'm just paranoid and iTunes is in fact perfectly capable of keeping old and new apps in the same library?
    Cheers

  • HT204394 How do i add audio to a single slide, not using soundtrack on ipad? but having new audio for each slide, on the ipad (not mac)?

    How do i add audio to single slide on keynote, not using soundtrack so i can have new sound on each slide controlled by my click? Have ipad so cannpt drag from itunes i dont think.

    Troubleshooting Apple Mail
    What does Mail/Window/Connection Doctor Show? If the server is red, select it and look at the Show Details box.
    Troubleshooting sending and receiving email messages
    Troubleshooting sending email messages

  • I've used Firefox for years. 2 days ago it wouldn't open. I uninstalled it using Revo uninstaller and put it back. Its still the same. Can anyone tell me how 2 fix this or change my mail settings for I Explorer. thx

    and now it just wont open can anyone tell me how 2 change my mail going 2 firefox and start going 2 i explorer please

    For gmail there are no settings to change, you can access gmail from any browser just by going to the gmail site and logging in.
    The [[Firefox will not start]] article should help with the problem you are having with Firefox.

  • I wanna ask you something. My bro has an iPhone 5s that disabled for 23 million because of the time changed to 1976. So, how to make it back into 2015, make it enabled without erase the data

    I  wanna Ask you something. My brother has an iPhone 5s that disabled for about 23 millions minutes  the time changed to 1976. So how to make it back into 2015 without waiting for 23 millions minutes later and enabled it without erasing any data? Please answer me ASAP because I really need it. Thank you for answer!

    Hello theshadowhunters,
    There is not much you can do to change the time back because he will not have access to change the time. The only option to get passed this is to restore the iPhone. Once the iPhone is restored and have a back up, you can put that back on once the restore is complete. For more information, take a look at the article below. 
    Forgot passcode for your iPhone, iPad, or iPod touch, or your device is disabled
    https://support.apple.com/en-us/HT204306
    Regards,
    -Norm G.  

  • How can i select some row from multiple row in the same group of data

    I want to select some row from multiple row in the same group of data.
    ColumnA        
    Column B
    1                  OK
    1                   NG
    2                   NG
    2                          NG
    3                          OK
    3                          OK
    I want the row of group of
    ColumnA if  ColumnB contain even 'NG'
    row , select only one row which  Column B = 'NG'
    the result i want = 
    ColumnA         Column B
    1                         NG
    2                   NG
    3                          OK
    Thank you

    That's some awful explanation, but I think this is what you were driving at:
    DECLARE @forumTable TABLE (a INT, b CHAR(2))
    INSERT INTO @forumTable (a, b)
    VALUES
    (1, 'OK'),(1, 'NG'),
    (2, 'NG'),(2, 'NG'),
    (3, 'OK'),(3, 'OK')
    SELECT f.a, MIN(COALESCE(f2.b,f.b)) AS b
    FROM @forumTable f
    LEFT OUTER JOIN @forumTable f2
    ON f.a = f2.a
    AND f.b <> f2.b
    GROUP BY f.a

  • The Credit Memo & Original Invoice do not have the same net due date.

    The issue is that for returns of goods from the customer, the credit memo that gets created does not have the same net due date as the original invoice.  To accomplish this, in the credit memo, the indicator "V" must be entered in the credit memo field BSEG-REBZG "Invoice Ref".  This will make the credit memo due based on the payment terms. In the OSS message 50388, SAP identifies a user exit in SDVFX008 which will fill field BSEG-REBZG with the value "V".  Doing this should automatically make the credit memo for returns due the same date as the original invoice.SAP says to do the following:
    The function module called by SDVFX008 is EXIT_SAPLV60B_008
    Make the ABAP coding in include program ZXVVFU08.
    Populate field ACCIT-REBZG with "V"
    Despite doing this , we couldnt get the same net due date as the credit memo & Original invoice.
    Can anyone help? POINTS WILL BE GIVEN.
    Thanks
    Anita

    Hi Anitha,
    Does the value 'V' gets paopulated?.
    I mean to ask whether the program goes into the user exit logic?.
    Please let me know.
    Thank you.
    Regards,
    Karun M

  • I can not sync my iPhone to the computer. I keep getting up an error message that synchronization does not want to start. I have uninstalled iTunes and then reinstall it. But the same warning box will appear. How can I get my phone in sync again?

    Can someone please help me get my iPhone to sync to your computer?
    I can not sync my iPhone to the computer. I keep getting up an error message that synchronization does not want to start. I have uninstalled iTunes and then reinstall it. But the same warning box will appear. How can I get my phone in sync again?

    Hello lenmin,
    Thanks for using Apple Support Communities.
    To help resolve this issue where you're repeatedly prompted to authorize with your Apple ID in iTunes when syncing, please follow the directions in the article below.
    iTunes: Missing folder or incorrect permissions may prevent authorization - Apple Support
    Have a great weekend,
    Alex H.

  • I have a iPad and a iPhone. I am logged into the same Apple ID on both devices. Every time I download something on my phone it automatically downloads on the iPad how do I turn this off?

    I have a iPad and a iPhone. I am logged into the same Apple ID on both devices. Every time I download something on my phone it automatically downloads on the iPad how do I turn this off?

    you need to turn automatic downloads off - its under settings>itunes & app store

  • We have 2 iphone 5s sharing the same apple ID.  When browsing Safari on one phone it automatically sends a link to that page to the other phone.  How do we turn this off please?

    We have 2 iphone 5s sharing the same apple ID.  When browsing Safari on one phone it automatically sends a link to that page to the other phone.  How do we turn this off please?

    @apup80
    It sounds that you are running the same iCloud account with two phones.  I recommend you to create a different iCloud account and you should be all set.
    Creating an iCloud account: Frequently Asked Questions - Apple Support
    iCloud: Remove your device from Find My iPhone

Maybe you are looking for