Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no value given for one or more required parameters

What's wrong in here, I always get some nasty errors even if the same code that I used earlier works. But when I apply it to other form it gives me the error above. here's my code:

Imports System.Data.OleDb
Public Class Updater2
    Public adminID As String
    Public adminName As String
    Public adminPass As String

    Private con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1.mdb;Jet OLEDB:Database Password=nrew123$%^;")
    Private com As OleDb.OleDbCommand

    Public Sub New()
        con.Open()
        com = New OleDb.OleDbCommand("Select * from admintable")
        com.Connection = con



    End Sub

    Public Sub updates()
        com.CommandText = "UPDATE admintable SET AdminName = '" & adminName & "', AdminPassS = '" & adminPass & "' WHERE ID = '" & adminID & "'"
        com.ExecuteNonQuery()

    End Sub
End Class

And here's the code in the button which tries to update the data:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        shikai.adminID = textbox1.text
        shikai.adminName = TextBox4.Text
        shikai.adminPass = TextBox3.Text






        shikai.updates()
        MsgBox("Successfully updated!")
    End Sub

what might be wrong here?

like image 222
user225269 Avatar asked Mar 04 '10 11:03

user225269


2 Answers

A good trick for dealing with a no value given for one or more required parameters error when developing for an Access back end is to grab the content of the CommandText and paste it into a dummy query in Access itself. Then Access will offer you a popup identifying which field is causing the problem (usually a typo, as in your case).

like image 184
hawbsl Avatar answered Oct 13 '22 10:10

hawbsl


The usual reason for this error is a missing or misspelled value. It seems likely that adminName is Null or a zero-length string.

like image 43
Fionnuala Avatar answered Oct 13 '22 12:10

Fionnuala