Trying to add a record??

D

dave

Sub upDateTheWeb()
Dim MachID = Session("selectedMachineID")
Dim owebservice As New localhost.updateMachine
Dim myDS As New DataSet
Dim myTable As DataTable = myDS.Tables("InventoryRecord")
Dim newRow As DataRow = myTable.NewRow() '****************************************ERROR
newRow("machine") = machine.Text
newRow("SERIAL_NO") = machSerialNo.Text
newRow("New_date") = machNewDate.Text
newRow("SPECS") = machSpecs.Text
newRow("MODEL") = MODEL.Text
newRow("ASKING_PRI") = ASKING_PRI.Text
myTable.Rows.Add(newRow)
Dim updDS As DataSet = owebservice.InsertInventoryRecord(myDS.GetChanges())
myDS.Merge(updDS)
myDS.AcceptChanges()


Public Function InsertInventoryRecord(ByVal custDS As System.Data.DataSet) As System.Data.DataSet
Dim results() As Object = Me.Invoke("InsertInventoryRecord", New Object() {custDS})
Return CType(results(0), System.Data.DataSet)
End Function



Public Function InsertInventoryRecord(ByVal custDS As DataSet) As DataSet
Dim custDA As SqlDataAdapter = New SqlDataAdapter
custDA.InsertCommand = New SqlCommand("INSERT INTO InventoryRecord (STOCK_NO, SERIAL_NO, New_date, SPECS, MODEL, ASKING_PRI) " & _
"Values(@STOCK_NO, @SERIAL_NO, @New_date, @SPECS, @MODEL, @ASKING_PRI)", myConnection)
custDA.InsertCommand.Parameters.Add("@STOCK_NO", SqlDbType.NChar, 5, "STOCK_NO")
custDA.InsertCommand.Parameters.Add("@SERIAL_NO", SqlDbType.NVarChar, 50, "SERIAL_NO")
custDA.InsertCommand.Parameters.Add("@New_date", SqlDbType.SmallDateTime, 20, "New_date")
custDA.InsertCommand.Parameters.Add("@SPECS", SqlDbType.NText, 2000, "SPECS")
custDA.InsertCommand.Parameters.Add("@MODEL", SqlDbType.NChar, 50, "MODEL")
custDA.InsertCommand.Parameters.Add("@ASKING_PRI", SqlDbType.Float, 15, "ASKING_PRI")
custDA.UpdateCommand = New SqlCommand("UPDATE Customers Set CustomerID = @CustomerID, " & _
"CompanyName = @CompanyName WHERE CustomerID = @OldCustomerID", myConnection)
custDA.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID")
custDA.UpdateCommand.Parameters.Add("@CompanyName", SqlDbType.NChar, 15, "CompanyName")
Dim myParm As SqlParameter = custDA.UpdateCommand.Parameters.Add("@OldCustomerID", SqlDbType.NChar, 5, "CustomerID")
myParm.SourceVersion = DataRowVersion.Original
custDA.DeleteCommand = New SqlCommand("DELETE FROM Customers WHERE CustomerID = @CustomerID", myConnection)
myParm = custDA.DeleteCommand.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID")
myParm.SourceVersion = DataRowVersion.Original
custDA.Update(custDS, "Customers")
InsertInventoryRecord = custDS
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top