![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Accessing DataSet.Tables I have a database query set up and am getting data. I want to select a specific CompanyName based upon a CompanyID. I am having no luck at narrowing down my output to the item (CompanyName) that I need. when I return $results I get: CompanyID CompanyName --------- ----------- ONE OneCompany $results = $DataSet.Tables[0].Select("CompanyID like '$code'") $results | Get-Member TypeName: System.Data.DataRow Name MemberType Definition ---- ---------- ---------- AcceptChanges Method System.Void AcceptChanges() BeginEdit Method System.Void BeginEdit() CancelEdit Method System.Void CancelEdit() ClearErrors Method System.Void ClearErrors() Delete Method System.Void Delete() EndEdit Method System.Void EndEdit() Equals Method System.Boolean Equals(Object obj) GetChildRows Method System.Data.DataRow[] GetChildRows(S... GetColumnError Method System.String GetColumnError(Int32 c... GetColumnsInError Method System.Data.DataColumn[] GetColumnsI... GetHashCode Method System.Int32 GetHashCode() GetParentRow Method System.Data.DataRow GetParentRow(Str... GetParentRows Method System.Data.DataRow[] GetParentRows(... GetType Method System.Type GetType() get_HasErrors Method System.Boolean get_HasErrors() get_Item Method System.Object get_Item(Int32 columnI... get_ItemArray Method System.Object[] get_ItemArray() get_RowError Method System.String get_RowError() get_RowState Method System.Data.DataRowState get_RowState() get_Table Method System.Data.DataTable get_Table() HasVersion Method System.Boolean HasVersion(DataRowVer... IsNull Method System.Boolean IsNull(Int32 columnIn... RejectChanges Method System.Void RejectChanges() SetAdded Method System.Void SetAdded() SetColumnError Method System.Void SetColumnError(Int32 col... SetModified Method System.Void SetModified() SetParentRow Method System.Void SetParentRow(DataRow par... set_Item Method System.Void set_Item(Int32 columnInd... set_ItemArray Method System.Void set_ItemArray(Object[] v... set_RowError Method System.Void set_RowError(String value) ToString Method System.String ToString() Item ParameterizedProperty System.Object Item(Int32 columnIndex... CompanyID Property System.String CompanyID {get;set;} CompanyName Property System.String CompanyName {get;set;} -- Respectfully, TomJ |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Accessing DataSet.Tables On Feb 14, 6:12*pm, Tom Johnson <TomJohn...@xxxxxx> wrote: Quote: > I have a database query set up and am getting data. I want to select a > specific CompanyName based upon a CompanyID. I am having no luck at narrowing > down my output to the item (CompanyName) that I need. when I return $results > I get: > > CompanyID * * * * * * * * * * * * * * * * * * * * * * * * * CompanyName > --------- * * * * * * * * * * * * * * * * * * * * * * * * * ----------- > ONE * * * * * * * * * * * * * * * * * * * * * * * * * * * * OneCompany > > $results = $DataSet.Tables[0].Select("CompanyID like '$code'") > $results | Get-Member > > * *TypeName: System.Data.DataRow > > Name * * * * * * *MemberType * * * * * *Definition > ---- * * * * * * *---------- * * * * * *---------- > AcceptChanges * * Method * * * * * * * *System.Void AcceptChanges() > BeginEdit * * * * Method * * * * * * * *System.Void BeginEdit() > CancelEdit * * * *Method * * * * * * * *System.Void CancelEdit() > ClearErrors * * * Method * * * * * * * *System.Void ClearErrors() > Delete * * * * * *Method * * * * * * * *System..Void Delete() > EndEdit * * * * * Method * * * * * * * *System.Void EndEdit() > Equals * * * * * *Method * * * * * * * *System..Boolean Equals(Object obj) > GetChildRows * * *Method * * * * * * * *System.Data.DataRow[] > GetChildRows(S... > GetColumnError * *Method * * * * * * * *System.String GetColumnError(Int32 > c... > GetColumnsInError Method * * * * * * * *System.Data.DataColumn[] > GetColumnsI... > GetHashCode * * * Method * * * * * * * *System.Int32GetHashCode() > GetParentRow * * *Method * * * * * * * *System.Data.DataRow > GetParentRow(Str... > GetParentRows * * Method * * * * * * * *System.Data.DataRow[] > GetParentRows(... > GetType * * * * * Method * * * * * * * *System.Type GetType() > get_HasErrors * * Method * * * * * * * *System.Booleanget_HasErrors() > get_Item * * * * *Method * * * * * * * *System.Object get_Item(Int32 > columnI... > get_ItemArray * * Method * * * * * * * *System.Object[] get_ItemArray() > get_RowError * * *Method * * * * * * * *System.String get_RowError() > get_RowState * * *Method * * * * * * * *System.Data.DataRowState > get_RowState() > get_Table * * * * Method * * * * * * * *System.Data.DataTable get_Table() > HasVersion * * * *Method * * * * * * * *System.Boolean > HasVersion(DataRowVer... > IsNull * * * * * *Method * * * * * * * *System..Boolean IsNull(Int32 > columnIn... > RejectChanges * * Method * * * * * * * *System.Void RejectChanges() > SetAdded * * * * *Method * * * * * * * *System.Void SetAdded() > SetColumnError * *Method * * * * * * * *System.Void SetColumnError(Int32 > col... > SetModified * * * Method * * * * * * * *System.Void SetModified() > SetParentRow * * *Method * * * * * * * *System.Void SetParentRow(DataRow > par... > set_Item * * * * *Method * * * * * * * *System.Void set_Item(Int32 > columnInd... > set_ItemArray * * Method * * * * * * * *System.Void set_ItemArray(Object[] > v... > set_RowError * * *Method * * * * * * * *System.Void set_RowError(String value) > ToString * * * * *Method * * * * * * * *System.String ToString() > Item * * * * * * *ParameterizedProperty System.Object Item(Int32 > columnIndex... > CompanyID * * * * Property * * * * * * *System.String CompanyID {get;set;} > CompanyName * * * Property * * * * * * *System.String CompanyName {get;set;} > > -- > Respectfully, > TomJ Select returns DataRow[] - that is to say, an _array_ of DataRow objects. When you perform $results | gm, powershell automatically passes each element in the array to get-member, and because there is only one element the net effect is that it looks like $results is a single DataRow object. Needless to say, you probably tried $results.CompanyName and got nothing. You actually need to use the syntax $results[0].CompanyName to choose the first element of the array. Don't worry.... you're not the first nor will you be the last to get bitten by this kind of thing ;-) - Oisin |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Accessing DataSet.Tables Thank you - what I ended up doing is $results | FOREACH-OBJECT { $CompanyID = $_.CompanyID $CompanyName = $_.CompanyName } return $CompanyName -- Respectfully, TomJ "Oisin (x0n) Grehan [MVP]" wrote: Quote: > On Feb 14, 6:12 pm, Tom Johnson <TomJohn...@xxxxxx> > wrote: Quote: > > I have a database query set up and am getting data. I want to select a > > specific CompanyName based upon a CompanyID. I am having no luck at narrowing > > down my output to the item (CompanyName) that I need. when I return $results > > I get: > > > > CompanyID CompanyName > > --------- ----------- > > ONE OneCompany > > > > $results = $DataSet.Tables[0].Select("CompanyID like '$code'") > > $results | Get-Member > > > > TypeName: System.Data.DataRow > > > > Name MemberType Definition > > ---- ---------- ---------- > > AcceptChanges Method System.Void AcceptChanges() > > BeginEdit Method System.Void BeginEdit() > > CancelEdit Method System.Void CancelEdit() > > ClearErrors Method System.Void ClearErrors() > > Delete Method System..Void Delete() > > EndEdit Method System.Void EndEdit() > > Equals Method System..Boolean Equals(Object obj) > > GetChildRows Method System.Data.DataRow[] > > GetChildRows(S... > > GetColumnError Method System.String GetColumnError(Int32 > > c... > > GetColumnsInError Method System.Data.DataColumn[] > > GetColumnsI... > > GetHashCode Method System.Int32 GetHashCode() > > GetParentRow Method System.Data.DataRow > > GetParentRow(Str... > > GetParentRows Method System.Data.DataRow[] > > GetParentRows(... > > GetType Method System.Type GetType() > > get_HasErrors Method System.Boolean get_HasErrors() > > get_Item Method System.Object get_Item(Int32 > > columnI... > > get_ItemArray Method System.Object[] get_ItemArray() > > get_RowError Method System.String get_RowError() > > get_RowState Method System.Data.DataRowState > > get_RowState() > > get_Table Method System.Data.DataTable get_Table() > > HasVersion Method System.Boolean > > HasVersion(DataRowVer... > > IsNull Method System..Boolean IsNull(Int32 > > columnIn... > > RejectChanges Method System.Void RejectChanges() > > SetAdded Method System.Void SetAdded() > > SetColumnError Method System.Void SetColumnError(Int32 > > col... > > SetModified Method System.Void SetModified() > > SetParentRow Method System.Void SetParentRow(DataRow > > par... > > set_Item Method System.Void set_Item(Int32 > > columnInd... > > set_ItemArray Method System.Void set_ItemArray(Object[] > > v... > > set_RowError Method System.Void set_RowError(String value) > > ToString Method System.String ToString() > > Item ParameterizedProperty System.Object Item(Int32 > > columnIndex... > > CompanyID Property System.String CompanyID {get;set;} > > CompanyName Property System.String CompanyName {get;set;} > > > > -- > > Respectfully, > > TomJ > Hi Tom, > > Select returns DataRow[] - that is to say, an _array_ of DataRow > objects. > > When you perform $results | gm, powershell automatically passes each > element in the array to get-member, and because there is only one > element the net effect is that it looks like $results is a single > DataRow object. Needless to say, you probably tried > $results.CompanyName and got nothing. You actually need to use the > syntax $results[0].CompanyName to choose the first element of the > array. > > Don't worry.... you're not the first nor will you be the last to get > bitten by this kind of thing ;-) > > - Oisin > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Accessing DataSet.Tables Thank You. I ended up doing . . $results | FOREACH-OBJECT { $CompanyID = $_.CompanyID $CompanyName = $_.CompanyName } return $CompanyName -- Respectfully, TomJ "Oisin (x0n) Grehan [MVP]" wrote: Quote: > On Feb 14, 6:12 pm, Tom Johnson <TomJohn...@xxxxxx> > wrote: Quote: > > I have a database query set up and am getting data. I want to select a > > specific CompanyName based upon a CompanyID. I am having no luck at narrowing > > down my output to the item (CompanyName) that I need. when I return $results > > I get: > > > > CompanyID CompanyName > > --------- ----------- > > ONE OneCompany > > > > $results = $DataSet.Tables[0].Select("CompanyID like '$code'") > > $results | Get-Member > > > > TypeName: System.Data.DataRow > > > > Name MemberType Definition > > ---- ---------- ---------- > > AcceptChanges Method System.Void AcceptChanges() > > BeginEdit Method System.Void BeginEdit() > > CancelEdit Method System.Void CancelEdit() > > ClearErrors Method System.Void ClearErrors() > > Delete Method System..Void Delete() > > EndEdit Method System.Void EndEdit() > > Equals Method System..Boolean Equals(Object obj) > > GetChildRows Method System.Data.DataRow[] > > GetChildRows(S... > > GetColumnError Method System.String GetColumnError(Int32 > > c... > > GetColumnsInError Method System.Data.DataColumn[] > > GetColumnsI... > > GetHashCode Method System.Int32 GetHashCode() > > GetParentRow Method System.Data.DataRow > > GetParentRow(Str... > > GetParentRows Method System.Data.DataRow[] > > GetParentRows(... > > GetType Method System.Type GetType() > > get_HasErrors Method System.Boolean get_HasErrors() > > get_Item Method System.Object get_Item(Int32 > > columnI... > > get_ItemArray Method System.Object[] get_ItemArray() > > get_RowError Method System.String get_RowError() > > get_RowState Method System.Data.DataRowState > > get_RowState() > > get_Table Method System.Data.DataTable get_Table() > > HasVersion Method System.Boolean > > HasVersion(DataRowVer... > > IsNull Method System..Boolean IsNull(Int32 > > columnIn... > > RejectChanges Method System.Void RejectChanges() > > SetAdded Method System.Void SetAdded() > > SetColumnError Method System.Void SetColumnError(Int32 > > col... > > SetModified Method System.Void SetModified() > > SetParentRow Method System.Void SetParentRow(DataRow > > par... > > set_Item Method System.Void set_Item(Int32 > > columnInd... > > set_ItemArray Method System.Void set_ItemArray(Object[] > > v... > > set_RowError Method System.Void set_RowError(String value) > > ToString Method System.String ToString() > > Item ParameterizedProperty System.Object Item(Int32 > > columnIndex... > > CompanyID Property System.String CompanyID {get;set;} > > CompanyName Property System.String CompanyName {get;set;} > > > > -- > > Respectfully, > > TomJ > Hi Tom, > > Select returns DataRow[] - that is to say, an _array_ of DataRow > objects. > > When you perform $results | gm, powershell automatically passes each > element in the array to get-member, and because there is only one > element the net effect is that it looks like $results is a single > DataRow object. Needless to say, you probably tried > $results.CompanyName and got nothing. You actually need to use the > syntax $results[0].CompanyName to choose the first element of the > array. > > Don't worry.... you're not the first nor will you be the last to get > bitten by this kind of thing ;-) > > - Oisin > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Accessing DataSet.Tables I'm also struggling with this, i have a configuration table in SQL that i need to query and variablize in order to perform functions in PS with. This example does well for a single row return, but I'm having trouble getting through a list, here is an example (not the literal example but this will do): Table1 'Config' Col1 = 'Servername' Col2 = 'Object' Col3 = 'Property' Col4 = 'Value' ...etc I am able to return the dataset, obviously, but i need to create a routine that can evaluate/process each row with the column data variables $Servername $Collection $Prop $Value etc.. Thanks very much in advance for all help! -JS "Tom Johnson" wrote: Quote: > Thank You. > I ended up doing . . > > $results | FOREACH-OBJECT { > $CompanyID = $_.CompanyID > $CompanyName = $_.CompanyName > } > > return $CompanyName > > -- > Respectfully, > TomJ > > > "Oisin (x0n) Grehan [MVP]" wrote: > Quote: > > On Feb 14, 6:12 pm, Tom Johnson <TomJohn...@xxxxxx> > > wrote: Quote: > > > I have a database query set up and am getting data. I want to select a > > > specific CompanyName based upon a CompanyID. I am having no luck at narrowing > > > down my output to the item (CompanyName) that I need. when I return $results > > > I get: > > > > > > CompanyID CompanyName > > > --------- ----------- > > > ONE OneCompany > > > > > > $results = $DataSet.Tables[0].Select("CompanyID like '$code'") > > > $results | Get-Member > > > > > > TypeName: System.Data.DataRow > > > > > > Name MemberType Definition > > > ---- ---------- ---------- > > > AcceptChanges Method System.Void AcceptChanges() > > > BeginEdit Method System.Void BeginEdit() > > > CancelEdit Method System.Void CancelEdit() > > > ClearErrors Method System.Void ClearErrors() > > > Delete Method System..Void Delete() > > > EndEdit Method System.Void EndEdit() > > > Equals Method System..Boolean Equals(Object obj) > > > GetChildRows Method System.Data.DataRow[] > > > GetChildRows(S... > > > GetColumnError Method System.String GetColumnError(Int32 > > > c... > > > GetColumnsInError Method System.Data.DataColumn[] > > > GetColumnsI... > > > GetHashCode Method System.Int32 GetHashCode() > > > GetParentRow Method System.Data.DataRow > > > GetParentRow(Str... > > > GetParentRows Method System.Data.DataRow[] > > > GetParentRows(... > > > GetType Method System.Type GetType() > > > get_HasErrors Method System.Boolean get_HasErrors() > > > get_Item Method System.Object get_Item(Int32 > > > columnI... > > > get_ItemArray Method System.Object[] get_ItemArray() > > > get_RowError Method System.String get_RowError() > > > get_RowState Method System.Data.DataRowState > > > get_RowState() > > > get_Table Method System.Data.DataTable get_Table() > > > HasVersion Method System.Boolean > > > HasVersion(DataRowVer... > > > IsNull Method System..Boolean IsNull(Int32 > > > columnIn... > > > RejectChanges Method System.Void RejectChanges() > > > SetAdded Method System.Void SetAdded() > > > SetColumnError Method System.Void SetColumnError(Int32 > > > col... > > > SetModified Method System.Void SetModified() > > > SetParentRow Method System.Void SetParentRow(DataRow > > > par... > > > set_Item Method System.Void set_Item(Int32 > > > columnInd... > > > set_ItemArray Method System.Void set_ItemArray(Object[] > > > v... > > > set_RowError Method System.Void set_RowError(String value) > > > ToString Method System.String ToString() > > > Item ParameterizedProperty System.Object Item(Int32 > > > columnIndex... > > > CompanyID Property System.String CompanyID {get;set;} > > > CompanyName Property System.String CompanyName {get;set;} > > > > > > -- > > > Respectfully, > > > TomJ > > Hi Tom, > > > > Select returns DataRow[] - that is to say, an _array_ of DataRow > > objects. > > > > When you perform $results | gm, powershell automatically passes each > > element in the array to get-member, and because there is only one > > element the net effect is that it looks like $results is a single > > DataRow object. Needless to say, you probably tried > > $results.CompanyName and got nothing. You actually need to use the > > syntax $results[0].CompanyName to choose the first element of the > > array. > > > > Don't worry.... you're not the first nor will you be the last to get > > bitten by this kind of thing ;-) > > > > - Oisin > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Using Tables within emails | Vista mail | |||
| Gridview with more than 2 tables | .NET General | |||
| Multiple tables | .NET General | |||
| tables in wlm | Live Mail | |||
| Hash Tables | PowerShell | |||