CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    1

    no value given for one or more parameters

    help pls i always get error i use it to get values in my table consist of both numbers and text in this part of my code

    brs = dbconn.Execute("SELECT * from Question where Categories = " & QuestCategory & " and Difficulty = " & Difficult & " and QNum = " & QuestNum)

    (error no value given for one or more parameters)

    in

    Set dbconn = New ADODB.Connection
    Set dbrs = New ADODB.Recordset

    Dim record1 As String
    Dim strapp As String
    strapp = IIf(Right$(App.Path, 1) = "\", "", "\database\")
    record1 = App.Path & strapp & "Custon Question Databank.mdb"

    dbconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & record1 & ";Persist Security Info=False"
    dbconn.Open
    dbrs = dbconn.Execute("SELECT * from Question where Categories = " & QuestCategory & " and Difficulty = " & Difficult & " and QNum = " & QuestNum)

    If dbrs.EOF = True Then
    MsgBox "No Question Exist", vbCritical
    RollCategory.Show
    RollCategory.Timer1.Interval = 150
    Else
    QuestionDisplayLbl.Caption = dbrs!Questions
    ALbl.Caption = dbrs!A
    BLbl.Caption = dbrs!B
    CLbl.Caption = dbrs!C
    DLbl.Caption = dbrs!D

    Correctans = Trim(dbrs!correct_answers)

    dbrs.Close
    dbconn.Close
    TimerPrize2.Enabled = False
    End If

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: no value given for one or more parameters

    Check your select statement. Make sure that all the fields referenced in your where clause actually exist in the table and are spelled exactly the same. Check the values of the variables and make sure they all contain a value.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: no value given for one or more parameters

    Use Debug.Print to save the actual SQL QUERY that gets calculated, and paste that into ACCESS connected to the same tables. Access will point to the character that fails, so it's easy to test, then put back into VB
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured