Hi--I'm trying to add information to a SQL database...I've had trouble getting it to update (and I'm only doing one entry at a time!). However, even one at a time gives me trouble. The red line of code gives me this error: Update requires a valid InsertCommand when passed DataRow collection with new rows. Please help me know what I'm doing wrong--I think it may be syntax, but I'm think the parameters are correct....
Code:Dim connect As New SqlConnection("Data Source=IRNTS4SQL;Initial Catalog=Materials;Integrated Security=True") connect.Open() Dim cmdLotNumber As New SqlCommand("SELECT [Lot_Name] From [FPAD Lot Log]", connect) Dim daLotNumber As New SqlDataAdapter(cmdLotNumber) Dim dsJobEntry As New DataSet daLotNumber.Fill(dsJobEntry, "LotData") cboLotNumber.DataSource = dsJobEntry.Tables("LotData") cboLotNumber.DisplayMember = "Lot_Name" Dim cmdEng As New SqlCommand("SELECT [Engineer_Name] from [FPAD Engineers] WHERE [Inactive] = 0", connect) 'WHERE [Inactive] = False", connect) 'Engineer_Name, [Inactive] FROM [FPAD Engineers] WHERE @Inactive = False", connect) Dim daEng As New SqlDataAdapter(cmdEng) daEng.Fill(dsJobEntry, "EngData") cboEngineer.DataSource = dsJobEntry.Tables("EngData") cboEngineer.DisplayMember = "Engineer_Name" Dim cmdTool As New SqlCommand("SELECT [Tool Type] from [FPAD Tool Types]", connect) 'WHERE [Inactive] = False", connect) 'Engineer_Name, [Inactive] FROM [FPAD Engineers] WHERE @Inactive = False", connect) Dim daTool As New SqlDataAdapter(cmdTool) daTool.Fill(dsJobEntry, "ToolData") daTool.UpdateCommand = New SqlCommand("Update [FPAD Tool Types]") 'REMOVE Dim newRow As DataRow = dsJobEntry.Tables("ToolData").NewRow() newRow("Tool Type") = "A24D" dsJobEntry.Tables("ToolData").Rows.Add(newRow) daTool.Update(dsJobEntry.Tables("ToolData")) cboTools.DataSource = dsJobEntry.Tables("ToolData") cboTools.DisplayMember = "Tool Type"




Reply With Quote
