By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Need help with code

P: n/a
Hi,

I have a Dataset named dsCMDetail, there is only one data table in the
dataset, the following code snippet does not compile:

Dim dtCMDetail as datatable
dtCMDetail = dsCMDetail.table(0)
lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this line
during compilation

Error messge: Class 'System.Data.Datatable' cannot be indexed because it has
no default property

What should I do?

Thanks in Advance
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Option Strict On

Dim dtCMDetail as datatable
dtCMDetail = dsCMDetail.Tables(0)
lblCreateDate.Text = dtCMDetail.Rows(0).Item("CreateDate").ToString()
or
lblCreateDate.Text = dtCMDetail.Rows(0)("CreateDate").ToString()

Greg

"Ed Chiu" <Ed****@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
Hi,

I have a Dataset named dsCMDetail, there is only one data table in the
dataset, the following code snippet does not compile:

Dim dtCMDetail as datatable
dtCMDetail = dsCMDetail.table(0)
lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this
line
during compilation

Error messge: Class 'System.Data.Datatable' cannot be indexed because it
has
no default property

What should I do?

Thanks in Advance

Nov 21 '05 #2

P: n/a
> lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this
line
during compilation
You need to specify the row and column name

lblCreateDate.Text =
dtCMDetail("CreateDate").Rows(Index).Column("Creat eDate").tostring 'error
on this line
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Use the following to email me

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Debug.WriteLine(ob("ufssz/cvsotAhsfbuTpmvujpotXjui/OFU", False))

End Sub

Private Function ob(ByVal email As String, ByVal inc As Boolean) As
String

Dim ch() As Char
Dim i As Int32
Dim stepValue As Int16

If inc Then stepValue = 1 Else stepValue = -1

ch = email.ToCharArray()

For i = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) + stepValue)
Next

Return New String(ch)

End Function
Time flies when you don't know what you're doing

"Ed Chiu" <Ed****@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com... Hi,

I have a Dataset named dsCMDetail, there is only one data table in the
dataset, the following code snippet does not compile:

Dim dtCMDetail as datatable
dtCMDetail = dsCMDetail.table(0)
lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this line during compilation

Error messge: Class 'System.Data.Datatable' cannot be indexed because it has no default property

What should I do?

Thanks in Advance

Nov 21 '05 #3

P: n/a
I must have stopped taking my medication, please ignore my post
;-)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
Nov 21 '05 #4

P: n/a
I believe it is the Item property of the Rows collections, not Column.

It is also the default indexer, so it can be omitted:

dtCMDetail("CreateDate").Rows(Index).Item("CreateD ate").tostring
or
dtCMDetail("CreateDate").Rows(Index)("CreateDate") .tostring

Greg
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:e5*****************@TK2MSFTNGP14.phx.gbl...
lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this

line
during compilation


You need to specify the row and column name

lblCreateDate.Text =
dtCMDetail("CreateDate").Rows(Index).Column("Creat eDate").tostring 'error
on this line
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Use the following to email me

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Debug.WriteLine(ob("ufssz/cvsotAhsfbuTpmvujpotXjui/OFU", False))

End Sub

Private Function ob(ByVal email As String, ByVal inc As Boolean) As
String

Dim ch() As Char
Dim i As Int32
Dim stepValue As Int16

If inc Then stepValue = 1 Else stepValue = -1

ch = email.ToCharArray()

For i = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) + stepValue)
Next

Return New String(ch)

End Function
Time flies when you don't know what you're doing

"Ed Chiu" <Ed****@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
Hi,

I have a Dataset named dsCMDetail, there is only one data table in the
dataset, the following code snippet does not compile:

Dim dtCMDetail as datatable
dtCMDetail = dsCMDetail.table(0)
lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this

line
during compilation

Error messge: Class 'System.Data.Datatable' cannot be indexed because it

has
no default property

What should I do?

Thanks in Advance


Nov 21 '05 #5

P: n/a
Changing the subject line threw me. (Forget my post then too!)

Greg

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:eZ****************@TK2MSFTNGP12.phx.gbl...
I must have stopped taking my medication, please ignore my post
;-)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.