locked
No value given for one or more required parameters. RRS feed

  • Question

  • User-564551718 posted

    I have the foolowing code [ which I'm using for recieving data from a table in order to create a chart]

    ////THIS WORKS OK
    Dim strCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\ME\My Documents\Visual Studio 2008\Projects\Aplicatie\Cotari.accdb"
    Dim conex As New OleDbConnection(strCon)

    //////HERE IS THE PROBLEM..THE SELECT STATEMENT  
    Dim sqlV As String = "SELECT Pret,Cantitate_v,Cantitate_c FROM [Cotari]" & _
                                 "WHERE [Data]='" & txtData.Value & "'" & _
    "AND [Actiune]='" & cmbActiune.ValueMember & "'"

    Dim da As New OleDbDataAdapter(sqlV, conex)
    Dim ds As New DataSet

    //////THE ERROR APPEARS HERE
    da.Fill(ds, "Cotari")----->No value given for one or more required parameters.
    
    
    The thing is I want to show a chart based on the date[which is a MONTLY CALENDAR CONTROL] and actiune[stock- which is a COMBO BOX] which the user selects.
    Dim strCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\ME\My Documents\Visual Studio 2008\Projects\Aplicatie\Cotari.accdb"
            Dim conex As New OleDbConnection(strCon)
          
            Dim sqlV As String = "SELECT Pret,Cantitate_v,Cantitate_c FROM [Cotari]" & _
                                 "WHERE [Data]='" & txtData.Value & "'" & _
                                 "AND [Actiune]='" & cmbActiune.ValueMember & "'"
    
            Dim da As New OleDbDataAdapter(sqlV, conex)
            Dim ds As New DataSet
    
            da.Fill(ds, "Cotari")
    
    Monday, June 20, 2011 3:35 PM

Answers

  • User-1199946673 posted

    If

    SELECT Pret,Cantitate_v,Cantitate_c FROM [Cotari]

    results in the same error, it means that either Pret, Cantitate_v or Cantitate_c isn't a valid fieldname in the table Cotari

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 21, 2011 3:40 AM

All replies

  • User197322208 posted

    1. Remove

      "WHERE [Data]='" & txtData.Value & "'" & _
    "AND [Actiune]='" & cmbActiune.ValueMember & "'"
    does it works?

    2. put
      "WHERE [Data]='" & txtData.Value & "'" & _
    does it works?
    3. put
      "WHERE  [Actiune]='" & cmbActiune.ValueMember & "'"
    does it works?

    Bet 1 +3 yes, 2 no. That means formatting of data is wrong ... you can try to format the value like yyyy-MM-dd
    Monday, June 20, 2011 3:42 PM
  • User-564551718 posted

    Every one of them result in the same error.

    Monday, June 20, 2011 3:54 PM
  • User197322208 posted

    Do you have a table named "Cotari'?

    Monday, June 20, 2011 4:09 PM
  • User-564551718 posted

    yes

    Monday, June 20, 2011 4:14 PM
  • User-1199946673 posted

    If

    SELECT Pret,Cantitate_v,Cantitate_c FROM [Cotari]

    results in the same error, it means that either Pret, Cantitate_v or Cantitate_c isn't a valid fieldname in the table Cotari

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 21, 2011 3:40 AM
  • User-564551718 posted

    You are completely right,I forgot that I have changed the names of Cantitate_V and Cantitate_c when I recreated the database, to Ordine_v and Ordine__c

    Thank you very much,I'll pay more attention next timeEmbarassed

    It works great now

    If

    SELECT Pret,Cantitate_v,Cantitate_c FROM [Cotari]

    results in the same error, it means that either Pret, Cantitate_v or Cantitate_c isn't a valid fieldname in the table Cotari

    Tuesday, June 21, 2011 3:49 AM
  • User-1199946673 posted

    Your welcome...

    Next thing you need to pay attention to is SQL injections!

    http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access

    Tuesday, June 21, 2011 4:28 AM