kshumway
asked on
Writing content of datatable to the database
I am trying to write the content of a data table back to a SQL Server table. It writes the first row, but on the second row, I get following error:
"Procedure or Function InsertHospitalInvoice has too many arguments specified."
I have reviewed everything and I cannot see why I am getting this error. Below is my code to call the stored procedure InsertHospitalInvoice. I've also provided a copy of the table design as well the Stored Procedure InsertHospitalInvoice in the attached word document.
Can anyone see where my bug is. Your help is greatly appreciated, Thank you stored-procedure-and-Table-desig.doc
"Procedure or Function InsertHospitalInvoice has too many arguments specified."
I have reviewed everything and I cannot see why I am getting this error. Below is my code to call the stored procedure InsertHospitalInvoice. I've also provided a copy of the table design as well the Stored Procedure InsertHospitalInvoice in the attached word document.
Can anyone see where my bug is. Your help is greatly appreciated, Thank you stored-procedure-and-Table-desig.doc
Sub InsHospInvData()
Dim cmdData As New SqlCommand()
Try
conn.Open()
cmdData.Connection = conn
For Each drow In dtHospInvData.Rows
cmdData.CommandText = "InsertHospitalInvoice"
cmdData.CommandType = CommandType.StoredProcedure
cmdData.Parameters.AddWithValue("@HID", drow.Item("HID"))
cmdData.Parameters.AddWithValue("@DeptCode", drow.Item("DeptCode"))
cmdData.Parameters.AddWithValue("@BillDate", drow.item("BillDate"))
cmdData.Parameters.AddWithValue("@InTests", drow.item("InTests"))
cmdData.Parameters.AddWithValue("@InAmount", drow.item("InAmount"))
cmdData.Parameters.AddWithValue("@OutTests", drow.item("OutTests"))
cmdData.Parameters.AddWithValue("@OutAmount", drow.item("OutAmount"))
cmdData.Parameters.AddWithValue("@OtherTests", drow.item("OtherTests"))
cmdData.Parameters.AddWithValue("@OtherAmount", drow.item("OtherAmount"))
cmdData.Parameters.AddWithValue("@SvDesc", drow.Item("SvDesc"))
cmdData.ExecuteNonQuery()
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
conn.Close()
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER