Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hhhhow to Reference a DataSet Field
Message
From
11/11/2002 16:35:43
 
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00720845
Message ID:
00721284
Views:
9
Sorry, Roland ... that's C# syntax for casting an object (in this case, casting the row's column value to a string). I don't know the syntax for casting in VB ... maybe Cathi will jump in and help (or you could try looking up cast in the Help).

~~Bonnie


>Hi Bonnie,
>
>The (string) in the line has a blue line under it. Syntax error.
>
>EdtMlsOfficeId.Text = (string)Form01_Ds1.Tables("Personnel").Rows(0)("MlsOfficeId")
>
>Any suggestions?
>
>Thanks
>Roland
>
>======================================================================
>>Roland,
>>
>>Row 0 refers to Row 0, not the current row.
>>
>>You may need to cast the row's value, like this:
>>
>>
>>EdtMlsOfficeId.Text = (string)Form01_Ds1.Tables("Personnel").Rows(0)("MlsOfficeId")
>>
>>
>>~~Bonnie
>>
>>
>>>Hi again,
>>>
>>>The following does not seem to work either.
>>>
>>> EdtMlsOfficeId.Text = Form01_Ds1.Tables("Personnel").Rows(0)("MlsOfficeId")
>>>
>>> sdMlsOfficeId = Form01_Ds1.PersonnelRow.("MlsOfficeId")
>>>
>>>The query builder includes fiels from 2 tables. Fields are from both tables.
>>>
>>>Any advise?
>>>
>>>Thanks
>>>Roland
>>>========================================================================
>>>
>>>>Hi,
>>>>
>>>>Does the Rows(0) indicate the current row or row 0 of the dataset?
>>>>
>>>>Thanks
>>>>Roland
>>>>===================================================
>>>>
>>>>>Its almost the same. VB uses () instead of []
>>>>>
>>>>>sAddress = ds1.Tables("Customer").Rows(0)("Name")
>>>>>
>>>>>
>>>>>
>>>>>>I don't do VB, but I'm pretty sure the syntax is the same for VB as it is for C#.
>>>>>>
>>>>>>Regular DataSet :
>>>>>>
>>>>>>sAddress = (string)ds1.Tables["Customer"].Rows[0]["Name"]
>>>>>>
>>>>>>-or-
>>>>>>
>>>>>>sAddress = ds1.Tables["Customer"].Rows[0]["Name"].ToString()
>>>>>>
>>>>>>
>>>>>>Typed DataSet :
>>>>>>
>>>>>>sAddress = ds1.Customer[0].Name
>>>>>>
>>>>>>
>>>>>>
>>>>>>HTH,
>>>>>>~~Bonnie
>>>>>>
>>>>>>
>>>>>>
>>>>>>>Hi,
>>>>>>>
>>>>>>>Using VB.net
>>>>>>>WinForm
>>>>>>>SqlAdapter
>>>>>>>
>>>>>>>How do you reference a DataSet Field Name directly in code to fill a variable?
>>>>>>>
>>>>>>>The following lines do not work.
>>>>>>>
>>>>>>>Public sAddress AS String
>>>>>>>
>>>>>>>sAddress = Ds1.Customer.Name
>>>>>>>sAddress = Customer.Name
>>>>>>>sAddress = Name
>>>>>>>
>>>>>>>What is the proper code?
>>>>>>>
>>>>>>>Thanks
>>>>>>>roland
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform