Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
934 views
in Technique[技术] by (71.8m points)

vb.net - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...