473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.ExecuteCommandTextE rrorHandling(Int32 hr)
at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS
dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.ExecuteReader(CommandB
ehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject 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
Nov 18 '05 #1
1 1109
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("nam e") = New
OleDb.OleDbParameter("name", "value")

Maybe this will help you?

/Lars

"Miguel Dias Moura" <we****@27NOSPAMlamps.com> skrev i meddelandet
news:OH**************@TK2MSFTNGP10.phx.gbl...
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.ExecuteCommandTextE rrorHandling(Int32 hr) at
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior,
Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.ExecuteReader(CommandB ehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject 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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
1
by: Miguel Dias Moura | last post by:
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...
30
by: Barry L. Bond | last post by:
Greetings! I just got a new Peet Brothers Ultimeter 2100 Weather Station. This new one has a way to display the heat index, if you press the "dew point" key twice. Being aware of all the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.