![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| VB 2005 Windows forms Data Structure | .NET General | |||
| System.Windows.Forms.Form | PowerShell | |||
| RE: Data error DataGridView DataGridViewComboBoxColumn | .NET General | |||
| Error with Windows.forms.form | PowerShell | |||
| [system.Windows.Forms.MessageBox] | PowerShell | |||