Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tables!

Status
Not open for further replies.

arpan

Programmer
Oct 16, 2002
336
IN
The following ASPX code works fine....
Code:
Sub Page_Load(obj As Object,ea As EventArgs)
  Dim objDS As New DataSet

  Dim objDT As New DataTable("Users")
  objDT.Columns.Add("ID",Type.GetType("System.Int32"))
  objDT.Columns.Add("FName",Type.GetType("System.String"))
  objDT.Columns.Add("LName",Type.GetType("System.String"))
  objDT.Columns("ID").AutoIncrement=True[red]
  objDS.Tables.Add(objDT)
  [/red]
  Dim objDR As DataRow=objDT.NewRow()
but if the code line in red color in the above code snippet is changed to
Code:
[red]  objDS.Tables("Users").Add(objDT)
[/red]
the following error gets generated:

'Add' is not a member of 'System.Data.DataTable'

Why so?

Thanks,

Regards,

Arpan [wavey2]
 
Code:
objDS.Tables("Users")
returns an object of type System.Data.DataTable, and it doesn't have an Add method. What you were doing the first time was correct.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks, Chip, for your response. As you say,
Code:
[red]objDS.Tables("Users")[/red]
returns an object of type System.Data.DataTable but then what does
Code:
[red]objDS.Tables[/red]
do? Doesn't it return an object of type System.Data.DataTable? If no, then what exactly does it do? Also the Add method is a member of which object?

Could you please suggest me some websites which explain the different objects & their corresponding methods & properties?

Please note that I am an ASP.NET newbie; so you might find my question a bit silly! Hence please be patient with me!

Thanks,

Regards,

Arpan [wavey2]
 
the Add is a member of dataset...adding a table to a dataset...

objDS.Tables

is a collection of tables within the dataset...however, it probably doesn't "return anything" because it's an incomplete syntax.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top