English 中文(简体)
我如何将两个栏的数值插入一个阵列,供日后使用。
原标题:How do I insert values from two columns into an array for later use with autocomplete?

Im在C#(窗口表格)和Server实施一个方案,在这两个栏中,我需要把“Q”阵列放在一个阵列。 我稍后将使用这一阵列,以便对某些文本Boxes进行自动填写。 规则是:

  • The array should be able to hold whatever the amount of strings I have in the columns, this amount may exceed 500 strings and is variable.
  • I will need the distinct values from the columns, no duplicates.

我认为,我应该利用“联合国”把两栏和SqlDataReader的所有座标同一个“同时”的周期混为一谈,把座标放在阵列中。

这里是一个例子表,用它向我解释:

----------------------------
|    name    |   surname   |
----------------------------
|    John    |   Jackson   |
----------------------------
|   Michael  |    Jones    |
----------------------------
|   Amanda   |    Lopez    |
----------------------------
|  Christina |    Lopez    |
----------------------------

因此,问询会如何看待,我如何把结果纳入一个阵列?

最佳回答

如果你想谨慎地利用:

SELECT DISTINCT name + surname FROM MyTable

如果你愿意,你可以这样做:

   SELECT Col1 FROM MyTable
    UNION
    SELECT Col2 FROM MyTable

工会只要有<代码>Col1和,就会有相同的数据类型。 一旦有了数据,你就可以把数据带回客户(通过数据交换)成为数据集、数据表或数据读物。

The rest should be simple, take the data and store it in an array of some sort. Either through some sort of loop

reader = GetData();
while(reader.read())
 {
  //store into an array...
 }

胶片服务器管理室复制

CREATE TABLE #Test
(
 col1 varchar(10),
 col2 varchar(10)
)

INSERT INTO #Test(col1, col2) VALUES( jon ,  jane )
INSERT INTO #Test(col1, col2) VALUES( jane ,  jane )
INSERT INTO #Test(col1, col2) VALUES( bob ,  phil )
INSERT INTO #Test(col1, col2) VALUES( marc ,  phil )
INSERT INTO #Test(col1, col2) VALUES( jon ,  jon )
INSERT INTO #Test(col1, col2) VALUES( jon ,  Jon )
INSERT INTO #Test(col1, col2) VALUES( jane1 ,  jane )
INSERT INTO #Test(col1, col2) VALUES( bob2 ,  phil )
INSERT INTO #Test(col1, col2) VALUES( marc2 ,  phil )
INSERT INTO #Test(col1, col2) VALUES( ste ,  jane )

SELECT col1 FROM #test UNION SELECT col2 FROM #test

DROP TABLE #Test

结果是:

bob
bob2
jane
jane1
jon
marc
marc2
phil
ste
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...