473,385 Members | 1,620 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,385 software developers and data experts.

Using Find Method On Primary Keys

Can anyone tell me how to use the DataRowCollection.Find Method on 3
primary keys, 2 of the keys are of the String type and the other is of
the DateTime type. I have tried the code below but get the following
error message .

An unhandled exception of type 'System.InvalidCastException' occurred
in system.data.dll

Additional information: Specified cast is not valid.
Dim dr As DataRow
Dim txt(2)as String
txt(0) = "30/07/05"
txt(1) = "FirstName"
txt(2) = "LastName"
dr = dtInfo.Rows.Find(txt)

Nov 21 '05 #1
3 2529
Do the order of array values and the primary columns match? Make sure the
first primary column is of type Date/Time followed by string values (or
reorder the array values accordingly).

"rnettle" <ro******@blueyonder.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Can anyone tell me how to use the DataRowCollection.Find Method on 3
primary keys, 2 of the keys are of the String type and the other is of
the DateTime type. I have tried the code below but get the following
error message .

An unhandled exception of type 'System.InvalidCastException' occurred
in system.data.dll

Additional information: Specified cast is not valid.
Dim dr As DataRow
Dim txt(2)as String
txt(0) = "30/07/05"
txt(1) = "FirstName"
txt(2) = "LastName"
dr = dtInfo.Rows.Find(txt)
Nov 21 '05 #2
Hi,

Dim dr As DataRow
Dim txt(2)as Object
txt(0) = DateTime.Parse("07/30/05")
txt(1) = "FirstName"
txt(2) = "LastName"
dr = dtInfo.Rows.Find(txt)
Ken
-------------------------
"rnettle" <ro******@blueyonder.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Can anyone tell me how to use the DataRowCollection.Find Method on 3
primary keys, 2 of the keys are of the String type and the other is of
the DateTime type. I have tried the code below but get the following
error message .

An unhandled exception of type 'System.InvalidCastException' occurred
in system.data.dll

Additional information: Specified cast is not valid.
Dim dr As DataRow
Dim txt(2)as String
txt(0) = "30/07/05"
txt(1) = "FirstName"
txt(2) = "LastName"
dr = dtInfo.Rows.Find(txt)

Nov 21 '05 #3
Thank for your replies the DateTime.Parse did the trick

Nov 21 '05 #4

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

Similar topics

112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
2
by: Scott Adams | last post by:
When calling the Find function of a DataRowCollection, one has two options: Overloads Public Function Find(ByVal key As Object) As DataRow or Overloads Public Function Find(ByVal keys() As...
5
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one...
5
by: Geoff Cayzer | last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section which is included below and was hoping for some comment on the article. -------------- Almost never use this auto-number...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
9
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for...
115
by: LurfysMa | last post by:
Most of the reference books recommend autonum primary keys, but the Access help says that any unique keys will work. What are the tradeoffs? I have several tables that have unique fields. Can...
4
by: charliej2001 | last post by:
This is my first post on groups and id like to say that already its helped me out loads, but can't quite find what im looking for now I have 3 tables storing information about people; Main, Temp...
1
by: =?Utf-8?B?Rm9lZg==?= | last post by:
I have a BindingSource with an underlying table with two primary keys. To set the position with one primary key works fine as shown in the code snippet below: Dim index As Integer =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.