inserting records using vb.net

I am trying to insert records into an SQL Server 2000 database and I keep getting the following error:

Cannot insert the value NULL into column 'ItemID', table 'RAM.dbo.Item_JS'; column does not allow nulls. INSERT fails.
The statement has been terminated.

The column ItemID is set to autonumber in the db. It is not a null value.  Here is my code:

Private Sub InsertRecord(ByVal partnumber As String, ByVal sourcecode As String, ByVal supercede As String, ByVal cost As String, ByVal itemname As String, ByVal listprice As String, ByVal lastupdateDt As String, ByVal status As String, ByVal insertdate As String, ByVal companyID As String, ByVal storeID As String, ByVal brandID As String, ByVal packageID As String)
        'Insert records into database table.
        Dim myConnString As String = "Data Source=*******;Initial Catalog=****;User ID=******;Password=******;"

        Dim myInsertQuery As String = "INSERT INTO Item_JS (ItemPartNumber, ItemSourceCode, ItemSupercede, ItemCost, ItemName, ItemListPrice, ItemLastUpdateDT, ItemStatus, ItemCreationDt, CompanyID, StoreID, BrandID, PackageID) VALUES('" & Trim(partnumber) & "', '" & Trim(sourcecode) & "', '" & Trim(supercede) & "', CONVERT(MONEY,'" & cost & "'), '" & Trim(itemname) & "', CONVERT(MONEY,'" & listprice & "'), '" & Trim(lastupdateDt) & "', '" & Trim(status) & "', '" & Trim(insertdate) & "', '" & Trim(companyID) & "', '" & Trim(storeID) & "', '" & Trim(brandID) & "', '" & Trim(packageID) & "'" & ")"

        Dim myConnection As New SqlConnection(myConnString)
        myConnection.Open()
        Dim myCommand As New SqlCommand(myInsertQuery, myConnection)
        myCommand.ExecuteNonQuery()
        myConnection.Close()
    End Sub

Any ideas?
ronayersAsked:
Who is Participating?
 
PaulHewsConnect With a Mentor Commented:
>The column ItemID is set to autonumber in the db.
First I would double check that this field has Identity set to true...  If this was converted from Access, you will need to do this manually.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.