Click here to Skip to main content
15,891,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
VB
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim c As Control

        For Each c In Me.Controls
            If TypeOf (c) Is PictureBox Then
                CType(c, PictureBox).Image = availableIcon
                AddHandler c.Click, AddressOf PictureBox7_Click

            End If

        Next
        Dim stSQL As String
        stSQL = "SELECT BookingID, Customer, Set FROM tblBOokings"

        Dim stConString As String
        stConString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\kalea\Documents\Access Database\BookingSystem.accdb"

        Dim conBookings As OleDbConnection
        conBookings = New OleDbConnection
        conBookings.ConnectionString = stConString
        conBookings.Open()

        Dim cmdSelectBookings As OleDbCommand
        cmdSelectBookings = New OleDbCommand
        cmdSelectBookings.CommandText = stSQL
        cmdSelectBookings.Connection = conBookings


        'Dim cmdSelectBookings As New As New OleDbCommand(stSQL, conBookings)

        Dim dsBookings As New DataSet
        Dim daBookings As New OleDbDataAdapter(cmdSelectBookings)
        daBookings.Fill(dsBookings, "Bookings")
        conBookings.Close()


What I have tried:

I'm receiving this error at:

daBookings.Fill(dsBookings, "Bookings")

Wondering if anyone could figure this out?
Posted
Updated 14-Aug-20 19:54pm
v3

Quote:

How should I solve "system.data.oledb.oledbexception: 'no value given for one or more required parameters.'?

Error looks explanatory here: Your query used is not as expected and needs to be setup correctly.

Quote:
stSQL = "SELECT BookingID, Customer, Set FROM tblBOokings"

Looking at it, it's a hardcoded query that you are using. First thought was something is missing in query while passing but seems you have plain vanilla SELECT. But then it seems the problem could be becasue of KEYWORD SET[^] there. You might have defined a column named 'Set' but once you put that here in query as done, it turns to different meaning and could raise error.

Change the column name and try. Or a quick validation by selecting all.
stSQL = "SELECT * FROM tblBOokings"

If the error goes away, then you can correct column name and then move on.


UPDATE:
Whatever I shared above, that should trow differet error though. The verbage of it. So in case above does not solve, you should still make the change.

Possibly, it's because of you trying to fill the dataset directly with adapter. You need to fill into a DataTable instead.

Try:
VB
Dim custTable As DataTable = New DataTable("Books")  
Dim dsBookings As New DataSet
dsBookings.Tables.Add(custTable) 
Dim daBookings As New OleDbDataAdapter(cmdSelectBookings)
daBookings.Fill(custTable, "Bookings") ' change made here from dataset to datatable
conBookings.Close()

Refer: OleDbDataAdapter.Fill Method (System.Data.OleDb) | Microsoft Docs[^]
 
Share this answer
 
v3
Comments
Sandeep Mewara 15-Aug-20 1:31am    
Updated with change from dataset to datatable that could be causing it.
SET is an SQL Keyword: you should not use it as a column name, but if you do then every time you use it you need to escape it. For Access, that would be:
SQL
SELECT BookingID, Customer, `Set` FROM tblBOokings
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900