Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Public Class Admission3

    Private Sub AdmissionBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
        Me.Validate()
        Me.AdmissionBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ButhdatabaseDataSet)

    End Sub

    Private Sub Admission3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'ButhdatabaseDataSet.Admission' table. You can move, or remove it, as needed.
        Me.AdmissionTableAdapter.Fill(Me.ButhdatabaseDataSet.Admission)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim conn As New OleDb.OleDbConnection
        Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Buthdatabase.accdb;Persist Security Info=False"
        Dim cmd As New OleDb.OleDbCommand

        Try
            conn.ConnectionString = connStr
            conn.Open()
            cmd.Connection = conn

            cmd.CommandText = "INSERT INTO Admission ([Patient'sName],[DateAttended],[RefferedBy],[Consultant],[Ward],[DateDischarged],[DischargedTo],[ConditionOnDischarge],[DischargeSummary]) " & _
                         "VALUES ([@Patient'sName],[@],[@DateAttended],[@RefferedBy],[@Consultant],[@Ward],[@DateDischarged],[@DischargedTo],[@ConditionOnDischarge],[@DischargeSummary]); "


            cmd.Parameters.AddWithValue("@Patient'sName", Patient_s_NameTextBox.Text)
            cmd.Parameters.AddWithValue("@DateAttended", Date_AttendedTextBox.Text)
            cmd.Parameters.AddWithValue("@RefferedBy", Reffered_ByTextBox.Text)
            cmd.Parameters.AddWithValue("@Consultant", ConsultantTextBox.Text)
            cmd.Parameters.AddWithValue("@Ward", WardTextBox.Text)
            cmd.Parameters.AddWithValue("@DateDischarged", Date_DischargedTextBox.Text)
            cmd.Parameters.AddWithValue("@DischargedTo", Discharged_ToTextBox.Text)
            cmd.Parameters.AddWithValue("@onditionOnDischarge", Condition_On_DischargeTextBox.Text)
            cmd.Parameters.AddWithValue("@DischargeSummary", Discharge_SummaryTextBox.Text)

            cmd.ExecuteNonQuery()
            conn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub


    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        AdmissionBindingSource.AddNew()

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        AdmissionBindingSource.RemoveCurrent()

    End Sub
End Class


What I have tried:

kindly help me out with this error
Posted
Updated 4-Aug-17 13:18pm
v2

1 solution

The error says that you have more parameters in your query than you add with AddWithValue. So let's look at your SQL query: you have this [@] parameter. I don't think you meant to put it in there. In any case it causes this error: if you count this one, you have 10 parameters in the query, while you only call AddWithValue 9 times.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900