Hi There,
I am trying to insert rows in the DB and cannot, please let me know it is throwing an exception "Could not find Stored Procedure Insert into IV00101"
Private Sub BtnSendToGP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSendToGP.Click
Dim VarItemNumber As String
Dim VarItemDescription As String
Dim VarUnitOfMeasure As String
Dim VarItemClass As String
Dim VarCurrentCost As String
Dim Conn As SqlConnection
Dim rowsAffected As Integer
Conn = New SqlConnection("Server = gpdb02; Initial Catalog=PRD; User=xx; Password=xxx1" & "Data Source=DynamicsGP;Integrated Security=SSPI;")
'Dim myCommand As SqlCommand = New SqlCommand("dbo.taUpdateCreateItemRcd", Conn)
'If Conn.State = ConnectionState.Open Then Conn.Close()
'Conn.Open()
Try
For cn As Integer = 0 To DtGridView.RowCount - 1
VarItemNumber = DtGridView(0, cn).Value.ToString()
VarItemDescription = DtGridView(3, cn).Value.ToString()
VarUnitOfMeasure = DtGridView(4, cn).Value.ToString()
VarItemClass = DtGridView(5, cn).Value.ToString()
VarCurrentCost = DtGridView(6, cn).Value.ToString()
Dim myCommand As SqlCommand = New SqlCommand("dbo.taUpdateCreateItemRcd", Conn)
If Conn.State = ConnectionState.Open Then Conn.Close()
Conn.Open()
myCommand.CommandType = Data.CommandType.StoredProcedure
myCommand.CommandText = "Insert into IV00101 Values(@I_vITEMNMBR, @I_vITMSHNAM, @I_vITMGEDSC, @I_vUOMSCHDL, @I_vITMCLSCD, @I_vCURRCOST)"
myCommand.Parameters.AddWithValue("@I_vITEMNMBR", VarItemNumber)
myCommand.Parameters.AddWithValue("@I_vITMSHNAM", VarItemDescription)
myCommand.Parameters.AddWithValue("@I_vITMGEDSC", "")
myCommand.Parameters.AddWithValue("@I_vITMTSHID", "")
myCommand.Parameters.AddWithValue("@I_vITEMSHWT", 0)
myCommand.Parameters.AddWithValue("@I_vTCC", "")
myCommand.Parameters.AddWithValue("@I_vCNTRYORGN", "")
myCommand.Parameters.AddWithValue("@I_vPurchase_Item_Tax_Schedu", "")
myCommand.Parameters.AddWithValue("@I_vSTNDCOST", 0)
myCommand.Parameters.AddWithValue("@I_vLISTPRCE", 0)
myCommand.Parameters.AddWithValue("@I_vNOTETEXT", "")
myCommand.Parameters.AddWithValue("@I_vALTITEM1", "")
myCommand.Parameters.AddWithValue("@I_vALTITEM2", "")
myCommand.Parameters.AddWithValue("@I_vITMTRKOP", 1)
myCommand.Parameters.AddWithValue("@I_vLOTTYPE", "")
myCommand.Parameters.AddWithValue("I_vLOTEXPWARN", 0)
myCommand.Parameters.AddWithValue("@I_vLOTEXPWARNDAYS", 0)
myCommand.Parameters.AddWithValue("@I_vINCLUDEINDP", 0)
myCommand.Parameters.AddWithValue("@I_vMINSHELF1", 0)
myCommand.Parameters.AddWithValue("@I_vMINSHELF2", 0)
myCommand.Parameters.AddWithValue("@I_vALWBKORD", 0)
myCommand.Parameters.AddWithValue("@I_vWRNTYDYS", 0)
myCommand.Parameters.AddWithValue("@I_vABCCODE", 1)
myCommand.Parameters.AddWithValue("@I_vUSCATVLS_1", "")
myCommand.Parameters.AddWithValue("@I_vUSCATVLS_2", "")
myCommand.Parameters.AddWithValue("@I_vUSCATVLS_3", "")
myCommand.Parameters.AddWithValue("@I_vUSCATVLS_4", "")
myCommand.Parameters.AddWithValue("@I_vUSCATVLS_5", "")
myCommand.Parameters.AddWithValue("@I_vUSCATVLS_6", "")
myCommand.Parameters.AddWithValue("@I_vIVIVACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVIVOFACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVCOGSACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVSLSACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVSLDSACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVSLRNACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVINUSACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVINSVACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVDMGACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVVARACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vDPSHPACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vPURPVACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vUPPVACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vIVRETACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vASMVRACTNUMST", "")
myCommand.Parameters.AddWithValue("@I_vKTACCTSR", 0)
myCommand.Parameters.AddWithValue("@I_vPRCHSUOM", CboUOM.Text)
myCommand.Parameters.AddWithValue("@I_vRevalue_Inventory", 1)
myCommand.Parameters.AddWithValue("@I_vTolerance_Percentage", 0.0)
myCommand.Parameters.AddWithValue("@I_vLOCNCODE", "STC01HOLD")
myCommand.Parameters.AddWithValue("@I_vPriceGroup", "DEFAULT")
myCommand.Parameters.AddWithValue("@I_vUSRDEFND1", "")
myCommand.Parameters.AddWithValue("@I_vUSRDEFND2", "")
myCommand.Parameters.AddWithValue("@I_vUSRDEFND3", "")
myCommand.Parameters.AddWithValue("@I_vUSRDEFND4", "")
myCommand.Parameters.AddWithValue("@I_vUSRDEFND5", "")
myCommand.Parameters.AddWithValue("@I_vITEMTYPE", 1)
myCommand.Parameters.AddWithValue("@I_vVCTNMTHD", 1)
myCommand.Parameters.AddWithValue("@I_vTAXOPTNS", 2)
myCommand.Parameters.AddWithValue("@I_vDECPLQTY", 1)
myCommand.Parameters.AddWithValue("@I_vDECPLCUR", 3)
myCommand.Parameters.AddWithValue("@I_vPurchase_Tax_Options", 2)
myCommand.Parameters.AddWithValue("@I_vKPCALHST", 1)
myCommand.Parameters.AddWithValue("@I_vKPERHIST", 1)
myCommand.Parameters.AddWithValue("@I_vKPTRXHST", 1)
myCommand.Parameters.AddWithValue("@I_vKPDSTHST", 1)
myCommand.Parameters.AddWithValue("@I_vPRICMTHD", 1)
myCommand.Parameters.AddWithValue("@I_vUseItemClass", 1)
myCommand.Parameters.AddWithValue("@I_vUpdateIfExists", 0)
myCommand.Parameters.AddWithValue("@I_vRequesterTrx", 0)
myCommand.Parameters.AddWithValue("@I_vITEMDESC", VarItemDescription)
myCommand.Parameters.AddWithValue("@I_vUOMSCHDL", VarUnitOfMeasure)
myCommand.Parameters.AddWithValue("@I_vITMCLSCD", VarItemClass)
myCommand.Parameters.AddWithValue("@I_vCURRCOST", VarCurrentCost)
myCommand.Parameters.AddWithValue("@O_iErrorState", 0)
myCommand.Parameters.AddWithValue("@oErrString", "")
myCommand.ExecuteNonQuery()
rowsAffected = myCommand.ExecuteNonQuery()
Next
Catch ex As Exception
MsgBox(ex.ToString)
Finally
If Conn.State = ConnectionState.Open Then
Conn.Close()
End If
End Try
MsgBox("All The Records Added To GP Successfully...", MsgBoxStyle.Information)
End Sub
Farquest