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

Can I do this on One line of code?

Seems silly I need two lines of code for this. Any way to do it in one?

Dim DcArray() As DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}

MyData.Tables(0).PrimaryKey = DcArray

Jan 19 '06 #1
5 859
Gregory,
Dim DcArray() As DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}

MyData.Tables(0).PrimaryKey = DcArray

No

Cor
Jan 19 '06 #2

"gregory_may" <None> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
Seems silly I need two lines of code for this. > Dim DcArray() As
DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}
MyData.Tables(0).PrimaryKey = DcArray Any way to do it in one?


Haven't tried it, but does this work?

With MyData.Tables(0)
.PrimaryKey _
= New DataColumn() { .Columns("PhoneNumber") }
End With

HTH,
Phill W.
Jan 19 '06 #3
MyData.Tables(0).PrimaryKey = New DataColumn()
{MyData.Tables(0).Columns("PhoneNumber")}
"gregory_may" <None> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
Seems silly I need two lines of code for this. Any way to do it in one?

Dim DcArray() As DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}

MyData.Tables(0).PrimaryKey = DcArray

Jan 19 '06 #4
"gregory_may" <None> schrieb
Seems silly I need two lines of code for this. Any way to do it in one?

Dim DcArray() As DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}

MyData.Tables(0).PrimaryKey = DcArray

mydata.Tables(0).PrimaryKey = New DataColumn()
{mydata.Tables(0).Columns("PhoneNumber")}

Two lines only due to word wrapping in the posting. :) Usually I would write

mydata.Tables(0).PrimaryKey = New DataColumn() { _
mydata.Tables(0).Columns("PhoneNumber") _
}

but than you had three lines instead of one.... Therefore I would change it
to

Dim DcArray() As DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}

MyData.Tables(0).PrimaryKey = DcArray
Ooops, that's what you already have.

;-)
Armin

Jan 19 '06 #5
Thanks guys, the New DataColumn() {} syntax is what I was after.

Thanks!

"Stephany Young" <noone@localhost> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
MyData.Tables(0).PrimaryKey = New DataColumn()
{MyData.Tables(0).Columns("PhoneNumber")}
"gregory_may" <None> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
Seems silly I need two lines of code for this. Any way to do it in one?

Dim DcArray() As DataColumn = {MyData.Tables(0).Columns("PhoneNumber")}

MyData.Tables(0).PrimaryKey = DcArray


Jan 19 '06 #6

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

Similar topics

6
by: calmar | last post by:
Hi all, I would like to use python for a replacement for some binutils. I would like to be able to pipe things into python. Actually I would not like writing a 'script' to handle the input, but...
23
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
3
by: Jim Bancroft | last post by:
Hi all, In VB6 I used a 3rd party tool for line numbering my source code, to help with debugging. However, in experimenting with VB .Net I've noticed that my exceptions automatically provide...
13
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
3
by: Mark | last post by:
Hi All, I have wrote a sub to record events from within the database. A lot of these events are errors. The sub has the module name and function/sub name passed to it to record to the table. My...
10
blazedaces
by: blazedaces | last post by:
Alright guys, so the title explains exactly my goal. The truth is I'm going to be reading in a lot of data from an xml file. The file is too large and there's too much data to store in arraylists...
19
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48...
1
by: todWulff | last post by:
Good day folks. Let me open with the statement that I am not a C++/C programmer. The environment that I am programming in is ARMbasic, an embedded BASIC targeted toward ARM-based...
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: 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...
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
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.