Hi,
Below is a bit of code from ASP.NET Unleashed which gives an
error and I can't figure out why. It uses the Authors table from
the standard Pubs database.
The error message is
"System.Argumen tException: Expecting 2 value(s) for the
key being indexed, but received 3 value(s)."
For the line:
intRowIndex = dvwAuthors.Find ( arrValues )
Can someone, please, explain what is wrong here.
Commenting out one of
arrValues( 0 ) = "Dull"
or
arrValues( 1 ) = "Ann"
seems to makes no difference to the error message.
++++++++++ ++++++++++ ++++++++++
<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.SqlClie nt" %>
<%
Dim dstAuthors As DataSet
Dim conPubs As SqlConnection
Dim dadAuthors As SqlDataAdapter
Dim dvwAuthors As DataView
Dim arrValues(2) As Object
Dim intRowIndex As Integer
' Grab Authors Table
dstAuthors = New DataSet()
conPubs = New SqlConnection(
"Server=localho st;UID=sa;PWD=s ecret;Database= Pubs" )
dadAuthors = New SqlDataAdapter( "Select * From Authors",
conPubs )
dadAuthors.Fill ( dstAuthors, "Authors" )
' Create DataView
dvwAuthors = dstAuthors.Tabl es( "Authors" ).DefaultView()
dvwAuthors.Sort = "au_lname, au_fname"
' Find Ann Dull
arrValues( 0 ) = "Dull"
arrValues( 1 ) = "Ann"
intRowIndex = dvwAuthors.Find ( arrValues )
' Display Phone Number
If intRowIndex <> -1 Then
Response.Write( dvwAuthors( intRowIndex ).Row( "Phone" ) )
Else
Response.Write( "Can't find Ann Dull" )
End If
%> 2 6211
I replaced these 3 lines:
arrValues( 0 ) = "Dull"
arrValues( 1 ) = "Ann"
intRowIndex = dvwAuthors.Find ( arrValues )
with this one and it works now.
dvwAuthors.RowF ilter = "au_lname='Dull ' and au_fname='Ann'"
was that the 'corrent' thing to do?
But it still doesn't explain the Find error. How do I code the
Find correctly?
On Wed, 23 Jun 2004 17:45:18 +0100, Zenobia
<6.**********@s pamgourmet.com> wrote: Hi,
Below is a bit of code from ASP.NET Unleashed which gives an error and I can't figure out why. It uses the Authors table from the standard Pubs database.
The error message is "System.Argumen tException: Expecting 2 value(s) for the key being indexed, but received 3 value(s)."
For the line: intRowIndex = dvwAuthors.Find ( arrValues )
Can someone, please, explain what is wrong here.
Commenting out one of arrValues( 0 ) = "Dull" or arrValues( 1 ) = "Ann" seems to makes no difference to the error message.
++++++++++ ++++++++++ ++++++++++
<%@ Page Language="VB" Debug="True" %> <%@ Import Namespace="Syst em.Data" %> <%@ Import Namespace="Syst em.Data.SqlClie nt" %>
<% Dim dstAuthors As DataSet Dim conPubs As SqlConnection Dim dadAuthors As SqlDataAdapter Dim dvwAuthors As DataView Dim arrValues(2) As Object Dim intRowIndex As Integer
' Grab Authors Table dstAuthors = New DataSet() conPubs = New SqlConnection( "Server=localh ost;UID=sa;PWD= secret;Database =Pubs" ) dadAuthors = New SqlDataAdapter( "Select * From Authors", conPubs ) dadAuthors.Fil l( dstAuthors, "Authors" )
' Create DataView dvwAuthors = dstAuthors.Tabl es( "Authors" ).DefaultView() dvwAuthors.Sor t = "au_lname, au_fname"
' Find Ann Dull arrValues( 0 ) = "Dull" arrValues( 1 ) = "Ann" intRowIndex = dvwAuthors.Find ( arrValues )
' Display Phone Number If intRowIndex <> -1 Then Response.Write( dvwAuthors( intRowIndex ).Row( "Phone" ) ) Else Response.Write( "Can't find Ann Dull" ) End If %>
On Wed, 23 Jun 2004 17:45:18 +0100, Zenobia
<6.**********@s pamgourmet.com> wrote:
Apologies for wasting people's time the book has an error in it.
It should be:
Dim arrValues(1) As Object
not:
Dim arrValues(2) As Object
as, of course, the lower array bound starts at 0. Hi,
Below is a bit of code from ASP.NET Unleashed which gives an error and I can't figure out why. It uses the Authors table from the standard Pubs database.
The error message is "System.Argumen tException: Expecting 2 value(s) for the key being indexed, but received 3 value(s)."
For the line: intRowIndex = dvwAuthors.Find ( arrValues )
Can someone, please, explain what is wrong here.
Commenting out one of arrValues( 0 ) = "Dull" or arrValues( 1 ) = "Ann" seems to makes no difference to the error message.
++++++++++ ++++++++++ ++++++++++
<%@ Page Language="VB" Debug="True" %> <%@ Import Namespace="Syst em.Data" %> <%@ Import Namespace="Syst em.Data.SqlClie nt" %>
<% Dim dstAuthors As DataSet Dim conPubs As SqlConnection Dim dadAuthors As SqlDataAdapter Dim dvwAuthors As DataView Dim arrValues(2) As Object Dim intRowIndex As Integer
' Grab Authors Table dstAuthors = New DataSet() conPubs = New SqlConnection( "Server=localh ost;UID=sa;PWD= secret;Database =Pubs" ) dadAuthors = New SqlDataAdapter( "Select * From Authors", conPubs ) dadAuthors.Fil l( dstAuthors, "Authors" )
' Create DataView dvwAuthors = dstAuthors.Tabl es( "Authors" ).DefaultView() dvwAuthors.Sor t = "au_lname, au_fname"
' Find Ann Dull arrValues( 0 ) = "Dull" arrValues( 1 ) = "Ann" intRowIndex = dvwAuthors.Find ( arrValues )
' Display Phone Number If intRowIndex <> -1 Then Response.Write( dvwAuthors( intRowIndex ).Row( "Phone" ) ) Else Response.Write( "Can't find Ann Dull" ) End If %> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Charles A. Lackman |
last post by:
Hello
I have created a Dataview and have sorted it on the Date and ShiftNumber
columns
this works great, but when I want to use the Find Method it gives me the
following error:
Expecting 2 value(s) for the key being indexed, but received 1 value(s).
I have tried the following:
Dim Names(1) as Object
|
by: Dazz |
last post by:
Hi
I desperately need some help. I want to have a DataView sorted
alphabetically by a specific column, then I want to find the first record
that begins with the letter the user inputs and get that record number. I
don't however want a filter as the user must still be able to scroll up and
down the DataView.
Thanks. Any help would be greatly appreciated.
|
by: kjvt |
last post by:
Based on a prior posting, I've written a function to convert a
recordset to a dataview. The first call to the function for a given
recordset works perfectly, but the second call always returns a
dataview with a count = 0. Can someone explain why and how I might
work around this problem?
Here is the code for my function:
Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _
As DataView
|
by: Tim Frawley |
last post by:
I need to return a DataRow or the Row Index in a DataSet wherein the
value I am attempting to find is not a primary key.
I have to do this often, more than 200 times when importing a file so
it needs to be fast.
Could I use a Dataview to filter for the value (which is unique) and
return either the DataRow object so I can modify it and put it back
into the DataSet the view is based on or somehow get the RowIndex in
the DataSet that the...
|
by: Aaron Smith |
last post by:
Has anyone had their IDE do this before? I have 3 grids that are bound
to related tables. They are each in their own tab page.
Grid1 - DS.Table1.Table2
Grid2 - DS.Table1.Table2.Table3
Grid3 - DS.Table1.Table4
Table1
/ \
Table4 Table2
| |
by: Derek |
last post by:
The following code never finds a matching row even when one exists. It
appears that the method thinks there is only one value being passed to the
method even though the object array that is passed has 2 elements, and both
elements have values.
Any ideas?
if ((dsReturned.Tables.Count > 0) && (dsReturned.Tables.Rows.Count > 0))
{
object objKeys = new object;
|
by: semedao |
last post by:
Hi , I am using asyc sockets p2p connection between 2 clients.
when I debug step by step the both sides , i'ts work ok.
when I run it , in somepoint (same location in the code)
when I want to receive 5 bytes buffer , I call the BeginReceive and then
wait on AsyncWaitHandle.WaitOne()
but it is signald imidiatly , and the next call to EndReceive return zero
bytes length , also the buffer is empty.
here is the code:
public static byte...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
Greetings,
I need to locate a row (or see if it exists) in a table contained in a
dataset. The DataView.Find method seems to work OK for one criteria but I
need to use 2 criterias. Is there anything in VB2005 that does was DLookUpd
does in Access - but for a table contained in a Dataset? I realize that
DLookUp works on Physical tables (not in-memory dataset tables), and I could
use a sqlDataReader to find my row from the physical...
|
by: Pravin Pujari |
last post by:
Hi All,
I am using .net framework 1.1 and c#. I have one problem regarding dataview.
I have one dataview to which sorting may be applied or may not be applied. I have one UI component where I am displaying the dataview. All rows in dataview are displayed in the sequence as they appear in dataview. i.e. there is direct mapping between dataview rows and UI rows.
I have subscribed ColumnChanged event of the datatable on which dataview is...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |