Auto Increment Not Working - SQL Identity field

I am new to Visual Basic & SQL server but have some experience in Access & VBA. But this is a steep learning curve!
I am banging my head against a wall with a problem..
All of my tables in this database are in the dataset. The main one being tblItems with a PK 'ITEMID'
I have 2 forms - the first one is used to lookup an item the second displays the item's full details.
On the first form (lookup) I have a 'Add New' button which launches the second form with the code - frmProductDetail.VItemsBindingSource.AddNew()
This opens the form with empty boxes as expected. I have a 'Save' button on the second form with the following code -
        Dim row As SASHItemsDataSet.tblItemsRow
        row = SASHItemsDataSet.tblItems.NewRow
        With row
            .ITEMCODE = txtItemCode.Text
            .ITEMDESCRIPTION = txtItemDescription.Text
            .CATEGORY = cmbItemCategory.SelectedValue
            .PURCHCOST = txtPurchCost.Text
            .SELLCOST = txtSellPrice.Text
            .UNIT = cmbUOM.SelectedValue
            .VATID = cmbVAT.SelectedValue
            .WHLOCATION = cmbWHLoc.SelectedValue
        End With
        SASHItemsDataSet.tblItems.Rows.Add()
        Try
            Me.Validate()
            Me.VItemsBindingSource.EndEdit()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "UPDATE FAILED")
        End Try
My problem is I get the error msg box with the following error 'Column 'ITEMID' does not allow nulls'
This field is set as a auto incrementing identity field with all the correct settings shown in Visual Studio so it shouldn't be coming back as null.
I have Googled for hours & tried all sorts with no luck..
I have clearly gone wrong somewhere but I can't work out where... any help appreciated!
James

This is the code on frmProductLookup that opens the form...
        frmProductDetail.Show()
        frmProductDetail.VItemsBindingSource.AddNew()
This is the code on frmProductDetail_Load...
        'TODO: This line of code loads data into the 'SASHItemsDataSet.tblVAT' table. You can move, or remove it, as needed.
        Me.TblVATTableAdapter.Fill(Me.SASHItemsDataSet.tblVAT)
        'TODO: This line of code loads data into the 'SASHItemsDataSet.tblWarehouseLocations' table. You can move, or remove it, as needed.
        Me.TblWarehouseLocationsTableAdapter.Fill(Me.SASHItemsDataSet.tblWarehouseLocations)
        'TODO: This line of code loads data into the 'SASHItemsDataSet.tblStockUnits' table. You can move, or remove it, as needed.
        Me.TblStockUnitsTableAdapter.Fill(Me.SASHItemsDataSet.tblStockUnits)
        'TODO: This line of code loads data into the 'SASHItemsDataSet.tblItemCategory' table. You can move, or remove it, as needed.
        Me.TblItemCategoryTableAdapter.Fill(Me.SASHItemsDataSet.tblItemCategory)
        'TODO: This line of code loads data into the 'SASHItemsDataSet.vItems' table. You can move, or remove it, as needed.
        'Me.VItemsTableAdapter.Fill(Me.SASHItemsDataSet.vItems)
        Me.VItemsTableAdapter.Fill(Me.SASHItemsDataSet.vItems)
        Me.VItemsBindingSource.Position = Me.VItemsBindingSource.Find("ITEMID", _passedText)
        Me.txtWKSName.Text = Environment.MachineName
        Me.txtSellPrice.Text = FormatCurrency(Me.txtSellPrice.Text)
        Me.txtPurchCost.Text = FormatCurrency(Me.txtPurchCost.Text)
        Me.txtPriceIVAT.Text = FormatCurrency(Me.txtSellPrice.Text + (Me.txtSellPrice.Text * 0.2))
On the tblItemTableAdapter this is the Command Text for the Insert Command...
INSERT INTO tblItems
                         (ITEMCODE, ITEMDESCRIPTION, UNIT, WHLOCATION, VATID, PREFSUPPLIER, CATEGORY, PURCHCOST, SELLCOST, INACTIVE)
VALUES        (@ITEMCODE,@ITEMDESCRIPTION,@UNIT,@WHLOCATION,@VATID,@PREFSUPPLIER,@CATEGORY,@PURCHCOST,@SELLCOST,@INACTIVE)
SQL Server Management Studio clearly shows the column as an Identity column. If I add a row through SSMS it does create an PK identity automatically. I have also dropped the ITEMID column & recreated through SSMS which has no effect.
I am now considering creating a separate form just for adding an item but I have managed it in Access but am just struggling with VB!
Thanks,
James

Similar Messages

  • Validation not working on Qualified Field!!!! is this Normal!!!

    Hi All,
    I have an Integer field in the Qualified table.
    Name-> Non Qualifier -> Type Text
    Code -> Qualifier -> type Integer
    Now, i need to write a  validation which throws error If user enters a number whose length is  less than 4 or greater than 4.
    The business requirement is User should enter Exactly 4 Numeric values. Not less and not more.
    As integer type field done not control Field length i have written a validation.
    I have written a validation..
    IF(IS_NULL(MAINLOOKUP.Code),1,IF(LEN(MAINLOOKUP.Code)<4 , 0 ))
    But this is not working.
    this works for a Normal Integer field which is in Main table, But this is not working when Code field is in Qualified table!!!
    Is this the normal Behaviour of MDM??
    Or am i missing something!!!
    Experts please provide your suggestions.
    Note: i changed the Code field to Text and made length as 4 in field property, But this is not controlling if user keys in only 2 values.
    So written the above validation on text field as well, But it does not work.
    Kind Regards
    Eva

    Hello Eva
    Ok
    Just imagine
    you have some record in your main table with some QLUT
    Qlut contain next fields
    item_name - type text
    item_value - type integer qualified = yes
    and list of values
    q1
    q2
    q3
    q4
    your main table contain next fields
    name-text
    Qlut->your Qlut
    qlut_code->text
    qlut_value_>text
    For qlut_code create assignment like Qlut.code
    For qlut_value create assignment like Qlut.value
    add some records to main table like this:
    name=test1
    in qlut select next:
    item name =Q1
    item value=1
    item name =Q2
    item value=2
    item name =Q3
    item value=3
    and another one record in main like this:
    name=test2
    in qlut select next:
    item name =Q1
    item value=1
    item name =Q3
    item value=3
    item name =Q4
    item value=4
    item name =Q3
    item value=33
    select both records and run both assignments
    If your assignments is correct
    In first main record you have got
    qlut_code=3:Q1;Q2;Q3
    qlut_value_>3:1;2;3
    for second main record you have got
    qlut_code=4:Q1;Q3;Q4;Q3
    qlut_value_>4:1;3;4;33
    Then you can use records values from qlut_code and qlut_value for validation
    This is work fine.
    I hope, you have got my point
    Regards
    Kanstantsin Chernichenka
    Edited by: kanstantsin_ch on Oct 6, 2011 1:35 PM

  • Auto brightness not working in ios6

    I updated my iPad (3rd gen) to ios6, but when the update is complete i found that the auto brightness not working, when i use the ipad on dark room the brightness not changing, when i use ios5.1 it changing.. Any solution and actually the problem is on ios or in the hardware? Looking for help asap...

    Well my device is different and since it is a iPhone 5, it is not being updated to iOS 6 but the issue is exactly the same. From my mind this could be up to software but also could be from an hardware issue. The thing is that even if it worked before iOS 6 for you the new software could have revealed hardware conflicts since the software interacts different with the hardware for some features. This would be the worst case scenario because I know that normally iPhone 4 devices if not the 8GB model will be out of warranty. For me this is just a small issue since my warranty is still one year :(
    I have contacted apple care for this issue and have get the info that it will be escalated to the engineering team, for further investigation. As I know there was also an issue with some proximity sensors at the beginning if the iPhone 4 models and I think there was an software fix for a lot of them. Hope for the best!!!
    I have also done a lot of Troubleshooting, reseted settings, content and settings, restored in dfu and recovery mode, restored with new .ipsw (iPhone OS), restored on different pc (so even this step gas downloaded a totally new .ipsw file), first on a Mac!
    Next step wis that I will let the battery drain low entirely, a Troubleshooting idea of an friend. This might empower the entire hardware for a restart. I am not really believing in this step but I will give it a try :)

  • AUto attendant not working

    Auto attendant not working .....
    If i assign AA script Transfer_v02.aef then i hear an just 1-2 seconds the script after that again it is just ringing ...
    Is there Option to set
    Please press the extension which you want to Call ...
    Eg: if i press 222 that time it should ring the 222 extension
    Please help this is the first time i am working on this stuff
    If i chnage the scrpt file then i can hear auto attendant not initiazlised..  please find the attched screen shot and back file for more details.
    Best Regards
    Shabeel

    Hi KMS, check the codec used between that GW using the FXO and the CTI RP.
    Check also the Calling Seach Space
    GW should be able to reach CTI Route Point and CTI ports partition.
    If you try other extension it works fine?

  • Valdiation rule does not work on PrimaryBillToCity field

    Hello to everyone,
    Valdiation rule does not work on PrimaryBillToCity field (and other address fields)
    Have someone a workaround ?
    Thanks.
    ML

    I do not believe it is possible to do validation on the address fields in the address block.

  • Auto keyframe and auto transition not working

    auto keyframe and auto transition not working and I have a creative cloud, in addition the auto keyframe works in the getting startel lessons....

    In order to use these you need to have the autokey frame and transition selected
    OFF   ON
    and have the first key checked then move the playhead to the new position and it should add the transition.
    Did you try this and it is not working?.

  • Auto dial not working

    Auto dial not working
    I'm using an iPad 4, with WiFi and Cellular and iOS 8.1.3
    In the past if I was searching for a hotel and found one I only had to tap on the phone number and it would dial using either Skype or MagicJack. It worked using Wi-Fi or my data plan. It was an absolutely valuable function especially when traveling.
    Now, when I click on a phone number, it says that it's going to exit the program (like Safari) and start a new program. When I click, Ok, nothing happens.
    I must have inadvertently changed some setting.
    Skype works, MagicJack works, but I must dial the number manually.
    I have tried turning "Handoff" off and on then rebooting, turning FaceTime off and on and rebooting (and every combination of those two programs and actions).
    To say the least, I am frustrated because it must be something obvious. (to everyone else!)
    Any ideas as to how to how I can get it to dial automatically again?
    Thanks for any assistance.

    IPAD user guide for IOS 8 is available on line at apple -
    you can download it in IBOOK or PDF format to refer to when you can't get connected to see it on-line
    http://support.apple.com/manuals
    Handoff is only for using with multiple devices - Iphone/Ipad/ipod
    This is the bit in Handoff on Phone calls
    Phone calls
    If your iPhone (with iOS 8) is nearby, you can make and receive phone calls on your other iOS devices and Mac computers. All devices must be on the same Wi-Fi network, and signed into FaceTime and iCloud using the same Apple ID.
    Make a phone call on iPad. Tap a phone number in Contacts, Calendar, or Safari. You can also tap a recent contact in the multitasking screen.
    Disable iPhone Cellular Calls. On your iPhone, go to Settings > FaceTime, then turn off iPhone Cellular Calls.
    You may have to use Face Time to make calls from the IPAD -- there are page or 2 on that --

  • Auto brightness not working on iPhone 5?

    On the iPhone 5 - In the settings, when flicking the auto brightness on/off the screen shows no change in brightness - whether in a completely dark room or with the lights on etc. My iPhone 4 has been updated to IOS6 and seems to be working normally (brightness auto adjusts in all situations).
    Anyone else have this problem of the auto brightness not working?

    There is nothing wrong with the auto brightness.
    When you have auto brightness enabled the slider works as the minimum brightness setting with auto brightness.
    If you have the slider too high the brightness cant reduce because youre not letting it.
    Set your brightness at about 25% and you'll see what I mean.

  • Infotype Screen Control (T588M) not working for additional fields to contro

    Hi,
    I have a requirement to enhance IT 0002 with fields LNAMR, FNAMR and CNAME. Also field preferred language.
    I have included LNAMR, FNAMR & CNAME as additional fields in the Include Screen 2040 elements, lay editor and maintained table T582c where i have assigned enhancement to the standard screen. These fields are getting displayed in infotype 0002
    But the issue is Infotype Screen Control (T588M) is not working for these fields to control the display or hide.
    Has any of you come across this issue? what could be the reason for this issue? Please suggest ASAP.
    Thanks in advance.
    Regards

    Hi Experts,
    Please help with your inputs and suggestions.
    Regards

  • Office 2013 Auto Archiving not working

    Dear Sir / Madam,
    We are using MS OFFICE 2013 with Windows 8.
    Problem we face is Auto Archiving not working at all. We have defined all the parameters, still it is not working. We are using Exchange Server and all the emails are Archived to local PST files after a defined time period.
    We have defined all the steps required to do Auto Archiving.
    Your help is required in this since we have tried all the options.
    Paloli Manoj

    Hi,
    What's the size or your archive.pst file? Please first make sure it's not getting close to 50 GB limit.
    If the size far below 50 GB, please try to use the Inbox Repair tool to scan and repair the archive.pst file. If the file is corrupt, the autoarchive will not happen.
    http://office.microsoft.com/en-in/outlook-help/repair-outlook-data-files-pst-and-ost-HA102749454.aspx?CTT=1
    For more troubleshooting steps, please refer to this:
    http://www.howto-outlook.com/faq/archivenotworking.htm
    Regards,
    Steve Fan
    TechNet Community Support

  • 3.4: keyword auto-completion not working for multiple levels

    Auto-completion does not work with higher level keywords, which used to work in LR 3.3 (IIRC).
    Example:
    I enter in the "Click here to add keywords" field:
    "He" then LR tries to complete the keyword by showing keywords starting with "He". Fine.
    But this is a keyword which does not exist so far, so I enter "Heldenplatz > W" because I want to have sorted it under Wien. If I'm not mistaken, LR 3.3 showed after entering the "W" a list of existing keywords starting with W (auto-completion for the one level higher tag). This is not the case anymore. I have to enter  "Heldenplatz > Wien" completely, which makes it slow and error-prone.
    Am I mistaken or can you reproduce it?
    Cheers

    GaryRowe wrote:
    How can it be, after all this time, that they still do not have effective regression testing in place ? Any sane development team (who wants to remain sane ;-) builds this as a priority ... unless they aren't given the resources?
    I think (don't remember though) that this never worked, so regression testing would not have helped.
    What is really to worry, that features aren't consequently and completely implemented (and tested). With a new option in Lightroom 3, Adobe has offered support for keywords with spaces. It seems that this feature as neither been thoroughly analysed or implemented. Thus, we face the currently inconsequent support of it:
    keyword completion only works with the first entered word, but when you enter a complete keyword hierarchy using the ">" letters
    filtering seems to have problems too

  • LOV filter - Auto Submit not working after the value is made to VS.filter

    JDeveloper 11.1.1.4.0
    I have cascading LOV filters for a table with fields id, deptid, projectName. The filters are for deptid and projectName. When I select a deptid, the projectNames belonging to that deptid should be populated. I have set Auto submit for deptid filter and partial trigger for project Name. So if I select a deptid and when I navigate to Project Name filter I get the list of project Names in the Project LOV filter.This worked fine as long as I didnt change the value for LOV to Vs.filtercriteria.deptid. Once I changed it the LOV filter for Project Names only got refreshed once I hit ENTER key after changing the value of Deptid. But I have to keep the value for LOV to Vs.filtercriteria.deptid. Other wise the records in the table after applying the filter values didnt function properly. I dont know whether the AutoSubmit does not work when the value is changed to Vs.filtercriteria.deptid

    duplicate post.
    Frank

  • Yoga 2 Pro tent mode and auto-rotate not working

    I have had a Yoga 2 Pro since June. Recently the Tent mode and auto-rotate features do not work.
    When I put the Yoga 2 Pro into Tent mode the keyboard and touch pad are still active underneth. However, they shutoff when in tablet mode. Lenovo Transition starts automatically and is running.
    Auto-rotate does not work at all now. The screen is un-locked.

    Dear NX3
    Welcome to Lenovo forums
    Please try to uninstal the Lenovo transition program and download the version in the below link and instal it
    http://support.lenovo.com/us/en/downloads/ds038767
    Thanks
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • Auto resolve not working for cached outlook

    We recently migrated from Exchange 2007 to 2010. One thing we have noticed is that auto resolve (to alias name) is not working for Outlook in cached mode.  Not in cached mode or via owa, it seems to work fine.

    Hi,
    Does the issue happen to all users or some specific users?
    Please check whether the issue happens in Outlook Online mode. If the issue only happens in Cached mode but not in Outlook Online mode, please create a new Outlook profile to have a try.
    If it doesn't work, please restart Microsoft Exchange File Distribution service in Exchange 2010 and Exchange 2007 then click Send/Receive > Send/Receive groups > Download Address Book to have a try.
    Regards,
    Winnie Liang
    TechNet Community Support

  • Auto Select not working in Photoshop CS6--Why?

    I'm experiencing the auto-select in Photoshop CS6 not working when it is checked and I click on different layers. It worked fine in 5.5, but I am now using PS CS6 cloud and it works only sporadically. Any reason why?
    Thanks in advance!
    -Jane

    Moving this discussion to photoshop Forum discussion.

Maybe you are looking for

  • Synch with Windows Media Player

    So, I'm converting to use Windows Media Player 0 as my music library manager. For the life of me, I cannot figure out how to make this thing auto-sync! I started from scratch and uploaded all music after a reformat. Now, I added a couple tunes to My

  • Can you help me delete imported photos from iPhone (4s) running ios 7?

    I made (what appears to be) the mistake of importing photos from my PC to my new iPhone 4s using itunes.  They now seem to be permanent occupants.  I can select them (in the "Moments" view in the Photos app)  but the trash can on lower right is alway

  • Change URL of a portal

    Hi, I have create a portal page, which I would like to make available under a different URL. In stead of http://sever:7778/pls/portal, I would like to use e.g. http://my_application. How can I obtain this?

  • Starting an Applescript by clicking on a cell

    Hello is it possible to start an Applescript (e.g. to create/update iCal-events) by clicking on a cell? Can I change the appearance of a checkbox that the gray button is invisible and I have the hole cell colored depending its value? Many thanks in a

  • FM 9 hard crash saving as or printing to PDF

    Hi, FrameMaker 9 crashes hard when printing to or saving as PDF. This is a 10-day-old installation on a new hard drive. FrameMaker 9 and Adobe Acrobat Pro Extended are all patched up. I even tried reinstalling Acrobat 9 Pro Ext using the Adobe setup