Connecting Tech Pros Worldwide Forums | Help | Site Map

Need help with code

Ed Chiu
Guest
 
Posts: n/a
#1: Nov 21 '05
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



Greg Burns
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Need help with code


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" <EdChiu@discussions.microsoft.com> wrote in message
news:20D73039-EEF0-4031-A6C8-C12F6CE44C6F@microsoft.com...[color=blue]
> 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
>
>[/color]


One Handed Man \( OHM - Terry Burns \)
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Need help with code


> lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this
line[color=blue]
> during compilation[/color]

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" <EdChiu@discussions.microsoft.com> wrote in message
news:20D73039-EEF0-4031-A6C8-C12F6CE44C6F@microsoft.com...[color=blue]
> 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[/color]
line[color=blue]
> during compilation
>
> Error messge: Class 'System.Data.Datatable' cannot be indexed because it[/color]
has[color=blue]
> no default property
>
> What should I do?
>
> Thanks in Advance
>
>[/color]


One Handed Man \( OHM - Terry Burns \)
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Need help with code


I must have stopped taking my medication, please ignore my post


;-)

--

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


Greg Burns
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Need help with code


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:e5K%23y8%23pEHA.376@TK2MSFTNGP14.phx.gbl...[color=blue][color=green]
>> lblCreateDate.Text = dtCMDetail("CreateDate").ToString() 'error on this[/color]
> line[color=green]
>> during compilation[/color]
>
> 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" <EdChiu@discussions.microsoft.com> wrote in message
> news:20D73039-EEF0-4031-A6C8-C12F6CE44C6F@microsoft.com...[color=green]
>> 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[/color]
> line[color=green]
>> during compilation
>>
>> Error messge: Class 'System.Data.Datatable' cannot be indexed because it[/color]
> has[color=green]
>> no default property
>>
>> What should I do?
>>
>> Thanks in Advance
>>
>>[/color]
>
>[/color]


Greg Burns
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Need help with code


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:eZVR19%23pEHA.2900@TK2MSFTNGP12.phx.gbl...[color=blue]
>I must have stopped taking my medication, please ignore my post
>
>
> ;-)
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
>[/color]


Closed Thread