![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Data Fetching and system.windows.forms.form & .datagridview what's wrong with this code??? the form shows but the control is not binding. help. $da = New-Object system.data.sqlclient.sqldataadapter $tbl = New-Object system.data.dataset $cn2 = new-object system.data.SqlClient.SQLConnection("Data Source=tcp:library;integrated Security=SSPI;Initial Catalog=cbprogram"); $cmd = new-object system.data.sqlclient.sqlcommand("select * from cblog", $cn2); $cn2.Open(); if ($cmd.ExecuteNonQuery() -ne -1) { echo "Failed"; } $da.fill($tbl,"test"); '$cmd.ExecuteScalar() ; [reflection.assembly]::loadwithpartialname("system.windows.forms"); $window = New-Object windows.forms.form; $grid = New-Object windows.forms.datagridview; $grid.DataSource = $tbl.tables("test"); $window.Controls.Add($grid); '$grid.DataBindings(); $window.ShowDialog(); |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Data Fetching and system.windows.forms.form & .datagridview you need to use the baseobject to add the datasource, e.g. $DG.DataSource = $DT.psObject.baseobject see also my datgrid GUI example here : http://mow001.blogspot.com/2006/05/p...pdate-and.html greetings /\/\o\/\/ "fixitchris" <fixitchris@discussions.microsoft.com> wrote in message news:26D871ED-8130-45E5-A26F-E427CCBBA40E@microsoft.com... > what's wrong with this code??? the form shows but the control is not > binding. > > help. > > $da = New-Object system.data.sqlclient.sqldataadapter > $tbl = New-Object system.data.dataset > $cn2 = new-object system.data.SqlClient.SQLConnection("Data > Source=tcp:library;integrated Security=SSPI;Initial Catalog=cbprogram"); > $cmd = new-object system.data.sqlclient.sqlcommand("select * from cblog", > $cn2); > $cn2.Open(); > if ($cmd.ExecuteNonQuery() -ne -1) > { > echo "Failed"; > } > $da.fill($tbl,"test"); > '$cmd.ExecuteScalar() ; > [reflection.assembly]::loadwithpartialname("system.windows.forms"); > $window = New-Object windows.forms.form; > $grid = New-Object windows.forms.datagridview; > $grid.DataSource = $tbl.tables("test"); > $window.Controls.Add($grid); > '$grid.DataBindings(); > $window.ShowDialog(); |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Data Fetching and system.windows.forms.form & .datagridview EXCELLENT! Thank YOU. $cn2 = new-object system.data.SqlClient.SQLConnection("Data Source=tcp:library;integrated Security=SSPI;Initial Catalog=cbprogram"); $da = New-Object system.data.sqlclient.sqldataadapter("select * from cblog", $cn2); $tbl = New-Object system.data.dataset; $cmd = new-object system.data.sqlclient.sqlcommand("select * from cblog", $cn2); $cn2.Open(); if ($cmd.ExecuteNonQuery() -ne -1) { echo "Failed"; } $da.fill($tbl,"CBLOG"); [reflection.assembly]::loadwithpartialname("system.windows.forms"); $window = New-Object windows.forms.form; $window.Size = New-Object system.drawing.size @(800,600); $grid = New-Object windows.forms.datagrid; $grid.DataSource = $tbl.psobject.baseobject; $grid.Dock = [system.windows.forms.dockstyle]::fill; $window.Text = "ROWS in [dbo].[cbprogram].[cblog] = $($tbl.Tables.Item(0).Rows.count)"; $window.Controls.Add($grid); $window.ShowDialog(); $cn2.close() |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| System.Windows.Forms.Form | William Holmes | PowerShell | 4 | 06-19-2008 10:02 AM |
| RE: Data error DataGridView DataGridViewComboBoxColumn | QSIDeveloper | .NET General | 3 | 03-09-2008 11:43 PM |
| Error with Windows.forms.form | Kuma | PowerShell | 6 | 09-30-2007 07:38 AM |
| Questions regarding system.windows.forms | Luke | PowerShell | 4 | 08-12-2007 10:35 AM |
| [system.Windows.Forms.MessageBox] | Anatoli | PowerShell | 2 | 08-09-2007 03:02 AM |