Dataset, DataAdapter HELP!!

ahbenshaut

Well-known member
Joined
Oct 29, 2004
Messages
62
Location
Alaska
Programming Experience
5-10
Ok, I'm a newbie and I just cannot figure out why this code doesn't work. What is supposed to do is grab the data from the form, place the data in a dataset and Insert into a SQL Server database. I have stepped through and the error lies when this is called "daCaseDetails.Update(ds, "CaseDetails")". The error states that "Procedure 'AddNewCaseDetails' expects parameter @claimantfirstname, which was not supplied." The data is in the dataset so I dont understand...

PLEASE HELP!!
Function GetAutoNumber() As Integer

Dim ds As New dsNewCase

Dim cn As New SqlConnection(cnnCheck21)

Dim daCaseDetails As SqlDataAdapter

Dim sqlSelect As New SqlCommand("SELECT * FROM CaseDetails", cn)

sqlSelect.CommandType = CommandType.Text

daCaseDetails =
New SqlDataAdapter

Dim cmdInsert As New SqlCommand("AddNewCaseDetails", cn)

Dim autonumber As Integer

cn.Open()

Try

daCaseDetails.SelectCommand = sqlSelect

cmdInsert.CommandType = CommandType.StoredProcedure

autonumber = cmdInsert.Parameters.Add("@casenumber", SqlDbType.Int).Direction = ParameterDirection.Output

cmdInsert.Parameters.Add("@claimantfirstname", SqlDbType.NVarChar, 255)

cmdInsert.Parameters.Add("@claimantlastname", SqlDbType.NVarChar, 255)

cmdInsert.Parameters.Add("@claimreceiveddate", SqlDbType.DateTime)

daCaseDetails.InsertCommand = cmdInsert

Dim drCaseDetails As DataRow

drCaseDetails = ds.Tables("CaseDetails").NewRow

drCaseDetails("ClaimantFirstName") = ClaimantFirstName

drCaseDetails("ClaimantLastName") = ClaimantLastName

drCaseDetails("ClaimReceivedDate") = ClaimReceivedDate

ds.Tables("CaseDetails").Rows.Add(drCaseDetails)

daCaseDetails.Update(ds, "CaseDetails")

Catch ex As Exception

MessageBox.Show(ex.ToString)

Catch sqlEx As SqlException

MessageBox.Show(sqlEx.ToString)

MessageBox.Show(autonumber)

cn.Close()

End Try

End Function

 
Back
Top