Can someone help me... I am new to vb.net with sql connection and I can't fix this error : variable name '@date' has already been declared. Variable names must be unique--
I need this to be fixed "ASAP" Im running out of time here because of the error
here is my code
thank you in advance for the reply
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
accdate = dtpdate.Value 'trial for the variable name '@date' error
Call conecDB()
Call disControl()
'Validation
Try
If invalidSaveEntry() = True Then
Call enaControl() 'enable text field
Exit Sub
End If
'Start Save
SQL = "Insert into tblstud_accdata(accdate,lastname,firstname,middlename,age) values(@date,@lname,@fname,@mname,@age)"
' Add Parameters to Command Parameters collection
comDB.Parameters.Add("@date", SqlDbType.Date).Value = accdate
comDB.Parameters.Add("@lname", SqlDbType.VarChar, 50).Value = txtLname.Text
comDB.Parameters.Add("@fname", SqlDbType.VarChar, 50).Value = txtFname.Text
comDB.Parameters.Add("@mname", SqlDbType.VarChar, 50).Value = txtMname.Text
comDB.Parameters.Add("@age", SqlDbType.Int).Value = txtAge.Text()
comDB.Prepare()
Call execComDB(SQL)
MsgBox("Record(s) saved...", MsgBoxStyle.Information, "Record(s) saved...")
If MsgBox("Do you want to add new record(s) ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation...") = MsgBoxResult.Yes Then
Call cleartxt()
Call enaControl()
Else
Me.Close() 'Close the form
' Display new record
SQL = "Select * from tblstud_accdata " & "order by accno desc"
Call dispRec(SQL)
Call frmSearch.dispRecCount() 'Display record count
'--- End of displaying new record
End If
Catch ex As Exception
MsgBox(ex.Message)
Me.Close()
Finally
Call closeDB()
End Try
End Sub