Debugging Immediate Window

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

Guest

Hey all,

when i'm in debug mode, is there a way to get to a certain record in a
dataset (say like in the Immediate window or something)?

thanks,
rodchar
 
This will return the datarow in the command window
?me.dsFleet.Tables(0).Rows(0) ' first table, firstrow

To return the datacolumn
?me.dsFleet.Tables("Customers").Rows(2)("Address") ' customer table, third
row, address datacolumn

--
Walt Ritscher
www.waltritscher.com\blogs
www.scandiasoft.com
yahoo email account is a spam trap - I will not reply to any mail sent to
this address.
 
rodchar said:
Hey all,

when i'm in debug mode, is there a way to get to a certain record in a
dataset (say like in the Immediate window or something)?

thanks,
rodchar

Yep. Asumming you've breakpointed your way into debug mode at the scope of the datset is such that
it is "alive" when your break point is hit you can use the Immediate window to :

? MyDataset.Tables.Count

...... you can do anything you like here

Note the ? is very imkportant as it asks a question which returns a result. You can also make
assignment by dropping the ?.

MyDataset.Tables(0).Rows(0)(1) = "Assign value"

hth
Richard
 
Richard said:
? MyDataset.Tables.Count

..... you can do anything you like here

Note the ? is very imkportant as it asks a question which returns a result. You can also make
assignment by dropping the ?.

Note that the use of a question mark to get the Basic language to print
something goes back to the late 1970's. If you entered "?" in your Quick
Basic program, it would be converted to "PRINT" automatically.
 
Note that the use of a question mark to get the Basic language to print
something goes back to the late 1970's. If you entered "?" in your Quick
Basic program, it would be converted to "PRINT" automatically.

Now thats legacy code!
I wonder if "?" still wears flares?
 
But what if I didn't know what the record number was. Let's say in a dataset
of 500 records I want to look at a record where a field = a specific value.
Kinda like, querying it in debug mode, is that possible?
 
Awesome, thank you.

Richard Myers said:
? MyDataset.MyTable.Select("CustomerId=5").Length

Will give the number of rows satifying the filter condition.

If you want to display the row

? MyDataset.MyTable.Select("CustomerId=5")(0)

Would return the first rowin the array of return rows that satisfied the criteria of the filter
condition. If you are using a untyped dataset you will get a bunch of lines about

Item: <cannot view indexed property>

so you will have to further refine your search

? MyDataset.MyTable.Select("CustomerId=5")(0)("My Property")

If you are using typed datasets your own version of the query below should pull up enough info to be
of use

? ctype(_customers.Customer.Select("CustomerId=90004")(0), dsCustomer.CustomerRow)

Here i am querying the Customer table in a dataset called _customer which is of type dsCustomer for
all rows which have a customerId of 90004. This will return an array of datarows;of which i am
casting the first from the base type of datarow as returned by the select method to the strongly
typed dsCustomer.CustomerRow:

Assumming a row matching this criteria is found the immediate window will return a list of field
values for this particular row:

{dsCustomer.CustomerRow}
AKey: "fffffff"
CustomerId: 90004
DCity: <error: an exception of type: {System.Data.StrongTypingException} occurred>
DCountry: <error: an exception of type: {System.Data.StrongTypingException} occurred>
DStateRegion: <error: an exception of type: {System.Data.StrongTypingException} occurred>
DStreet1: <error: an exception of type: {System.Data.StrongTypingException} occurred>
DStreet2: <error: an exception of type: {System.Data.StrongTypingException} occurred>
DSuburb: <error: an exception of type: {System.Data.StrongTypingException} occurred>
DZipcode: <error: an exception of type: {System.Data.StrongTypingException} occurred>
Email: <error: an exception of type: {System.Data.StrongTypingException} occurred>
Fax: <error: an exception of type: {System.Data.StrongTypingException} occurred>
HasErrors: False
Item: <cannot view indexed property>
Item: <cannot view indexed property>
Item: <cannot view indexed property>
Item: <cannot view indexed property>
ItemArray: {Length=26}
Name: "Rodger Bannister"
PCity: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PCountry: <error: an exception of type: {System.Data.StrongTypingException} occurred>
Phone1: "021 240 7444"
Phone2: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PhoneFree: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PStateRegion: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PStreet1: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PStreet2: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PSuburb: <error: an exception of type: {System.Data.StrongTypingException} occurred>
PZipcode: <error: an exception of type: {System.Data.StrongTypingException} occurred>
RowError: ""
RowState: Unchanged
SalesCallStatus: 4
SalesRoute: 2
SalesTerritoryId: 3
Table: {dsCustomer.CustomerDataTable}
Website: <error: an exception of type: {System.Data.StrongTypingException} occurred>


Anything like <error: an exception of type: {System.Data.StrongTypingException} occurred> generally
means that the strongly typed dataset contains a value of Null for that field.

hth
Richard
 
Back
Top