excel 同 vb 1 問

2007-08-10 5:16 pm
我想問我依+想正1個database用excel同埋vb! 將excel裡面既資料放入我想寫個個database道! 我個database基本上係用黎放bin人地係我個excel個清單果道search個樣object出黎!
請問有冇人會幫到我用咩language先可以做到search哩樣野同埋個language係咩!
我係外行人唔係識咁多請大家多多睇諒唔好見怪!

回答 (2)

2007-08-10 8:06 pm
✔ 最佳答案
放bin = 方便 ?? 妳是國語人, 還是懶音人(懶人)... ..."

妳咪話用VB囉, 唔得咩...

不過妳個problem, 其實係點架,
淨係用excel都可以搵野架喇. 使咩搞咁多野搞!?

vlookup應該咁妳用.

唔明就再問啦.
參考: Give me 10 bugs !!
2007-08-11 6:27 am
Sorry, Im too lazy to type chinese.

Apart from using VBA in excel to make some look up columns equivilent to Relational database "view" , you can also do the searching using VB itself

simple searching,, you can open a connection from your excel spreadsheet. use ADO to get a DataSet object. and within the DataSet, you can get 1 or more DataTable object, and those tables contain all the information from the excel.

Now, the most important part will be do the search and sort

Dim da as new OledbDataAdaptor
' create your command for import excel data blah blah blah..
Dim ds as new DataSet
da.Fill(ds)
Dim dt as DataTable = ds.Table(0)

Dim drs as DataRow() = dt.Select("[field1] = [value1] AND [field2] = [value2]")

You can see the DataTable object allow to use similar to a SQL statement, by passing in the string constraint as the parameter.

There is also override method Select, allow you to pass in 2 parameters, the 2nd one will be for sorting.

Be aware that the output for 'DataTable.Select' will be DataRow array instead of a DataTable object.

if you wana convert the DataRow array back into DataTable, you need to clone a new DataTable object from the initial one, and use "Import" function to import rows from the DataRow Array to the new DataTable.


That is base on VB.net 2.0
參考: My own knowledge, Im a Web developer, and programmer


收錄日期: 2021-04-13 18:04:25
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070810000051KK00919

檢視 Wayback Machine 備份