error message: No value given for one or more required parameters.
that falls in dr = cmd.ExecuteReader
need help

Imports System.Data.OleDb

Public Class Form1
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim strSQL As String
Dim dr As OleDbDataReader
' Dim ctr As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database1.mdb")
conn.Open()
End Sub

Private Sub enter1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles accept1.Click
strSQL = "SELECT * ATM WHERE pincode = '" & pinenter.Text & "'"
cmd = New OleDbCommand(strSQL, conn)
dr = cmd.ExecuteReader
'strSQL = " SELECT * FROM ATM WHERE pincode =" & "'" & pinenter.Text & "'"
'cmd = New OleDbCommand(strSQL, conn)
'dr = cmd.ExecuteReader
ctr = ctr + 1
If dr.HasRows Then
'While dr.Read
Form4.balance.Visible = dr("Balance_Inquiry")
Me.Hide()
Form3.Show()

If ctr = 3 Then
Me.Hide()
Form9.Show()
Form9.Timer1.Enabled = True
End If

Else
MsgBox("WRONG PIN !")
pinenter.Text = ""

End If

Your strSql is incorrect. Use the second strSql which is correct.

strSQL = "SELECT * ATM WHERE pincode = '" & pinenter.Text & "'"

= Incorrect

strSQL = " SELECT * FROM ATM WHERE pincode =" & "'" & pinenter.Text & "'"

= correct

Hi dorothy

If pincode is a numeric field in your database then you should probably use

strSQL = " SELECT * FROM ATM WHERE pincode = " & pinenter.Text

If it is a text field, then use

strSQL = " SELECT * FROM ATM WHERE pincode = '" & pinenter.Text & "'"

If you still get the same error, there's probably something wrong with field/table names. ALso, it might help to check pinenter.text before you create strSQL - to make sure it's in the right format - probably "1234" or similar.

commented: thumbs up! +0

hhh ....!! ) thank you thank you crapulency and AndreRet
thanks for the help. .. really appreciate

it works in accessing the pin
but in the form3 there is an error occurred when i press the button in selecting the balance inquiry saying that Data type mismatch in criteria expression. that falls in the cmd.ExecuteNonQuery() . do i need to remove that cmd.ExecuteNonQuery()?

Imports System.Data.OleDb

Public Class Form3
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim StrSQL As String
Dim dr As OleDbDataReader
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database1.mdb")
conn.Open()
Button15.Enabled = False
Button16.Enabled = False
Button14.Enabled = False
End Sub

Private Sub enter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles accept3.Click
Form4.Visible = True
Me.Visible = False
End Sub

Private Sub balancebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles balancebtn.Click
StrSQL = "UPDATE ATM SET Balance_Inquiry ='" & Form4.balance.Text & "'"
cmd = New OleDbCommand(StrSQL, conn)
cmd.ExecuteNonQuery()
Me.Hide()
Form4.Show()
End Sub

Private Sub cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel3.Click
Me.Hide()
Form1.Show()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form5.Show()
End Sub
End Class

No, data type mismatch is probably because you are trying to save a string to a integer field. In other words, in your table the field "Balance" is set to only accept numbers and not any text. Confirm that only a number is returned from form 3/balance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.