How do I create a stand alone Dataset by ADO.NET?

  • Thread starter Thread starter Zoo
  • Start date Start date
Z

Zoo

Hi,All.

I have the code written below which runs on VB6 and ADO.
And I want migrate this onto VB.NET 2003 and ADO.NET.
Could anybody give me a sample?

Dim Rs As New ADODB.RecordSet
With Rs
$B!!!!(B.Fields.Append "ID", adLongVarChar, 10, adFldRowID
$B!!!!(B.Fields.Append "Name", adChar, 50, adFldUpdatable
$B!!!!(B.CursorType = adOpenKeyset
$B!!!!(B.LockType = adLockOptimistic
$B!!!!(B.Open
End With
 
As an example ..

dim DataTable as new DataTable()
DataTable.Columns.Add("Foo", Type.GetType("System.String"))
DataTable.Columns.Add("Bar", Type.GetType("System.Int32"))

You can also get into alot more properties of the DataColumn if you use the
form

dim Column as new DataColumn()
'set some properties on the column
DataTable.Columns.Add(Column)

Cheers,

Greg
 
Thank you Greg Young.
I didn't know DataTable. I just knew only DataReader.
It's thanks to you that I know DataTable.
That helps me so much.
 
Greg,

It is as this in the documentation on MSDN where it is completely copied
from C#

However this goes as well and you can than use the intellisence from VBNet

dim DataTable as new DataTable()
DataTable.Columns.Add("Foo", GetType(System.String))
DataTable.Columns.Add("Bar", GetType(System.Int32))

Just to let you know for next time.

Cor
 
Back
Top