473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Find Method On Primary Keys

Can anyone tell me how to use the DataRowCollecti on.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.Invalid CastException' 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.Fin d(txt)

Nov 21 '05 #1
3 2551
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******@bluey onder.co.uk> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Can anyone tell me how to use the DataRowCollecti on.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.Invalid CastException' 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.Fin d(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.Fin d(txt)
Ken
-------------------------
"rnettle" <ro******@bluey onder.co.uk> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Can anyone tell me how to use the DataRowCollecti on.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.Invalid CastException' 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.Fin d(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
10306
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, share your experience in using IDENTITY as PK .
2
5672
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 Object) As DataRow This function is easy to use if the primary key of your DataTable consists of only one field. How can you use the Find functions if the primary key consists of two database fields (composite key)?
5
4329
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 child table (StudentProgress). The course progress records how a student progresses on a course. I have one course (History) and one student called Maya. I now want to record her grade (64). If I do this in Access using a form, then the form...
5
4543
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 field as the primary key of the table. If you are thinking of hiring an Access programmer or consultant ask
18
12644
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 relations with the table containing no primary key. Do I just create two primary keys on the table that does not contain any primary key for this to become a composite primary key? Thank you in advance! Still a newbie,
9
3904
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 eg: area.txt, school.txt, students.txt.... and so on (ok?!?) now, 1. area code used in the school.txt must be defined in the area.txt (Primary key in area => area_code defined in area.txt & Foreign key on school => area_code defined in...
115
6218
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 I use them as primary keys or should I define an autonum primary key? One table has information about the 50 states in the US. The table looks like this:
4
2141
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 and Dupl. What I want to do, using VBA, is check each record in the Temp table (10-50 records) against each record in the Main table (1000+ records); if any records then match, I want to store them in the Dupl table. The 3 tables are identical in...
1
12142
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 = myBindingSource.Find("ColumnName", myColumnName) If (index <-1) Then myBindingSource.Position = index End If How should I set the BindingSource.Position with two or more primary keys?
0
8411
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
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,...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
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...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
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
2
1732
bsmnconsultancy
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...

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.