views:

67

answers:

2

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?

+2  A: 

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

Remou
+2  A: 

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).

hawbsl
nice one, its really nice here, there are lots of good tricks I can get from monsters like you, thanks:)