Error: "No value given for one or more required parameters

Error: "No value given for one or more required parameters

am 23.08.2007 18:07:47 von Gwen Crutcher

I keep getting the error "No value given for one or more required
parameters", but not sure why. Can anyone please look at my code snipet
and see if you see any reason why I could be getting this error. I am
just trying to update a record using MS Access 2003 as the front end.
This code is in VB.NET

Private Sub cmdUpdate_Click()
On Error GoTo Err_cmdUpdate_Click

Dim rstUsers As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
Dim strSQL As String


strSQL = "select dbo_tbl_Users.* from dbo_tbl_Users " & "where
dbo_tbl_Users!EmpRec=" & "'" & Me.cboEmpRec & "'"
rstUsers.Open strSQL, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic


If Not IsNull(Me.cboEmpRec.value) Then
rstUsers!EmpRec = Me.cboEmpRec.value
End If

If Not IsNull(Me.txtEmpID) Then
rstUsers!EmpID = Me.txtEmpID
Else
MsgBox "Please enter an employee number", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If


If Not IsNull(Me.txtEmpName) Then
rstUsers!EmpName = Me.txtEmpName
Else
MsgBox "Please enter an employee name", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

If Not IsNull(Me.cboStatus.value) Then
rstUsers!Status = Me.cboStatus.value
Else
MsgBox "Please enter a status for the employee", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

If Not IsNull(Me.txtUName) Then
rstUsers!UserName = Me.txtUName
Else
MsgBox "Please enter a user name for the employee", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

If Not IsNull(Me.txtPass) Then
rstUsers!Password = Me.txtPass
Else
MsgBox "Please enter a password for the employee", vbOKOnly
GoTo Exit_cmdUpdate_Click
End If

rstUsers.Update
rstUsers.Close

MsgBox "Employee Record has been updated successfully.", vbOKOnly
DoCmd.Close
cboEmpRec = Null
txtEmpID = Null
txtEmpName = Null
txtPass = Null
cboStatus = Null
txtUName = Null
Set rstUsers = Nothing


Exit_cmdUpdate_Click:
Exit Sub

Err_cmdUpdate_Click:
MsgBox Err.Description
Resume Exit_cmdUpdate_Click

End Sub



*** Sent via Developersdex http://www.developersdex.com ***

Re: Error: "No value given for one or more required parameters

am 23.08.2007 18:45:23 von reb01501

Gwen Crutcher wrote:
> I keep getting the error "No value given for one or more required
> parameters", but not sure why. Can anyone please look at my code
> snipet and see if you see any reason why I could be getting this
> error. I am just trying to update a record using MS Access 2003 as
> the front end. This code is in VB.NET
>

There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic asp newsgroup. ASP.Net is
a different technology from classic ASP. While you may be lucky enough
to find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to a newsgroup
where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.

But read on.

> Private Sub cmdUpdate_Click()
> On Error GoTo Err_cmdUpdate_Click
>
> Dim rstUsers As New ADODB.Recordset
> Dim fld As ADODB.Field
> Dim strField As String
> Dim strSQL As String
>
>
> strSQL = "select dbo_tbl_Users.* from dbo_tbl_Users " & "where
> dbo_tbl_Users!EmpRec=" & "'" & Me.cboEmpRec & "'"

Either debug your application and inspect the contents of strsql, or
look at the result of

Response.Write strSQL

If that doesn't tell you the problem, show it to us.
Lesson: you cannot debug a sql statement without knowing what it is.
While it helps to see the code that generates the statement, there is no
substitute for looking at the result of that code.



PS. You may wish to read up on sql injection and using parameters before
you get much further on in your learning curve.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.