Need help with code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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("CreateDate").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
 
I must have stopped taking my medication, please ignore my post


;-)
 
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("CreateDate").tostring
or
dtCMDetail("CreateDate").Rows(Index)("CreateDate").tostring

Greg
 
Changing the subject line threw me. (Forget my post then too!)

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top