none
no value given for one or more required parameters RRS feed

  • Question

  •  Private Sub RefreshData()
            If Not cnn.State = ConnectionState.Open Then
                'open connection
                cnn.Open()
            End If

            Dim da As New OleDb.OleDbDataAdapter("SELECT stdid as [ID], " & _
                                                "stdname as [Name], NickName, BirthdayMonth, BirthdayDay, BirthdayYear, Mobile, Landline, Email, Facebook, Talents, Hobbies, Dancing, Singing, Acting, Baking/Cooking, Instruments, Inst, Others, Othrs, Pre-Encounter, Encounter, Post-Encounter, Sol1, Sol2, Sol3, Address " & _
                                                "FROM student ORDER BY stdid", cnn)


        
            Dim dt As New DataTable
            'fill data to datatable
            da.Fill(dt) -- i'm having a error with this one :(((

            'offer data in data table into datagridview
            Me.dgvData.DataSource = dt

            'close connection
            cnn.Close()
        End Sub
    Saturday, May 25, 2013 5:07 AM

Answers

  • Hello,

    What is the error you are getting? Also for column names with characters such as / and - you might consider enclosing them i.e. [Pre-Encounter] and [Backing/Cooking].

    Example

    Dim da As New OleDb.OleDbDataAdapter( _
        "SELECT stdid as [ID], " & _
        "stdname as [Name], NickName, BirthdayMonth, BirthdayDay, " & _
        "BirthdayYear, Mobile, Landline, Email, Facebook, Talents, " & _
        "Hobbies, Dancing, Singing, Acting, [Baking/Cooking], " & _
        "Instruments, Inst, Others, Othrs, [Pre-Encounter], " & _
        "Encounter, [Post-Encounter], Sol1, Sol2, Sol3, Address " & _
        "FROM student ORDER BY stdid", cnn)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Saturday, May 25, 2013 1:49 PM
  • You will get the error mentioned in the title of your post if you have a parameter marker ("?") in the query text but do not add a parameter to the command object.  However, I don't see one in the sample code you posted.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    Saturday, May 25, 2013 6:26 PM

All replies

  • Hello,

    What is the error you are getting? Also for column names with characters such as / and - you might consider enclosing them i.e. [Pre-Encounter] and [Backing/Cooking].

    Example

    Dim da As New OleDb.OleDbDataAdapter( _
        "SELECT stdid as [ID], " & _
        "stdname as [Name], NickName, BirthdayMonth, BirthdayDay, " & _
        "BirthdayYear, Mobile, Landline, Email, Facebook, Talents, " & _
        "Hobbies, Dancing, Singing, Acting, [Baking/Cooking], " & _
        "Instruments, Inst, Others, Othrs, [Pre-Encounter], " & _
        "Encounter, [Post-Encounter], Sol1, Sol2, Sol3, Address " & _
        "FROM student ORDER BY stdid", cnn)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Saturday, May 25, 2013 1:49 PM
  • You will get the error mentioned in the title of your post if you have a parameter marker ("?") in the query text but do not add a parameter to the command object.  However, I don't see one in the sample code you posted.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

    Saturday, May 25, 2013 6:26 PM