Simple SQL question. Can you check what am i doing wrong? Thank You.

Discussion in 'ASP .Net' started by Miguel Dias Moura, Jun 18, 2004.

  1. Hello,

    i have an ASP.net / VB page which i want to display 1 record of a database
    acording to this:

    1. The page receives a variable name "Explicador" in the URL. Example:
    "Explicador = Jonh Smith"
    2. The database where the records are is named "explicador"
    3. Two of the database fields are "NomePrimeiro" and "NomeUltimo". The
    "Explicador" field is created as follows:
    "Explicador" = "NomePrimeiro" + " " + "NomeUltimo"

    The SQL code i am using is this:

    SELECT *, NomePrimeiro + ' ' + NomeUltimo as Explicador
    FROM explicador
    WHERE Explicador = ?

    <Parameter Name="@Explicador" Value='<%#
    IIf((Request.QueryString("Explicador") <> Nothing),
    Request.QueryString("Explicador"), "") %>' Type="WChar"
    /></Parameters></MM:DataSet>

    Can you tell me what am i doing wrong?

    Basicly when the URL has Explicador = John Smith, it should be loaded the
    record that has NomePrimeiro = "John" and NomeUltimo = "Smith"

    I am getting this error:

    System.Data.OleDb.OleDbException: No value given for one or more required
    parameters.
    at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
    at
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
    dbParams, Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
    Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
    behavior, String method)
    at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
    at
    System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandB
    ehavior behavior)
    at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
    startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
    CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
    Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
    behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
    Int32 maxRecords, String srcTable)
    at DreamweaverCtrls.DataSet.DoInit()

    Thank You,
    Miguel
     
    Miguel Dias Moura, Jun 18, 2004
    #1
    1. Advertising

  2. Miguel Dias Moura

    Lars Netzel Guest

    Since you are using the = ? way of using parameters, you need to set the
    parameter befor eyou start retrieving data from the Seledt statement.

    In the Adapter add the parameter before you fill.

    Me.OleDbDataAdapter1.SelectCommand.Parameters("name") = New
    OleDb.OleDbParameter("name", "value")

    Maybe this will help you?

    /Lars



    "Miguel Dias Moura" <> skrev i meddelandet
    news:...
    > Hello,
    >
    > i have an ASP.net / VB page which i want to display 1 record of a database
    > acording to this:
    >
    > 1. The page receives a variable name "Explicador" in the URL. Example:
    > "Explicador = Jonh Smith"
    > 2. The database where the records are is named "explicador"
    > 3. Two of the database fields are "NomePrimeiro" and "NomeUltimo". The
    > "Explicador" field is created as follows:
    > "Explicador" = "NomePrimeiro" + " " + "NomeUltimo"
    >
    > The SQL code i am using is this:
    >
    > SELECT *, NomePrimeiro + ' ' + NomeUltimo as Explicador
    > FROM explicador
    > WHERE Explicador = ?
    >
    > <Parameter Name="@Explicador" Value='<%#
    > IIf((Request.QueryString("Explicador") <> Nothing),
    > Request.QueryString("Explicador"), "") %>' Type="WChar"
    > /></Parameters></MM:DataSet>
    >
    > Can you tell me what am i doing wrong?
    >
    > Basicly when the URL has Explicador = John Smith, it should be loaded the
    > record that has NomePrimeiro = "John" and NomeUltimo = "Smith"
    >
    > I am getting this error:
    >
    > System.Data.OleDb.OleDbException: No value given for one or more required
    > parameters.
    > at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32

    hr)
    > at
    >

    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
    > dbParams, Object& executeResult)
    > at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&

    executeResult)
    > at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
    > Object& executeResult)
    > at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
    > behavior, String method)
    > at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
    > at
    >

    System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandB
    > ehavior behavior)
    > at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
    > startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
    > CommandBehavior behavior)
    > at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32

    startRecord,
    > Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
    > behavior)
    > at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32

    startRecord,
    > Int32 maxRecords, String srcTable)
    > at DreamweaverCtrls.DataSet.DoInit()
    >
    > Thank You,
    > Miguel
    >
    >
     
    Lars Netzel, Jun 18, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jm
    Replies:
    4
    Views:
    456
  2. Miguel Dias Moura
    Replies:
    1
    Views:
    426
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Apr 1, 2004
  3. Miguel Dias Moura
    Replies:
    4
    Views:
    3,336
    Miguel Dias Moura
    Jun 23, 2004
  4. Miguel Dias Moura
    Replies:
    1
    Views:
    460
  5. Shapper

    Cookies. Simple Question. Thank You.

    Shapper, Apr 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    432
    David Young
    Apr 29, 2005
Loading...

Share This Page