|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Filling a DataGrid with a DataSetbut I cannot get past the very first step of simply filling a DataGrid from a DataSet. My code is Dim sqlStmt As String = "Select VendorName, StartWeek from InventorySchedule Where FinishDate is Null and StartWeek<'" & Now & "'" Dim cmdDB As New SqlCommand(sqlStmt, connDB) Dim dgridTarget As New DataGrid Dim adapter As New SqlDataAdapter() Dim ds As New DataSet ' create the table style in the grid Dim dgtsStyle As DataGridTableStyle Dim dgtsColumn As DataGridTextBoxColumn dgtsStyle = New DataGridTableStyle ' set the tablestyle mapping to the table name With dgtsStyle .MappingName = "VendorsToCount" End With dgtsColumn = New DataGridTextBoxColumn dgtsColumn.MappingName = "VendorName" dgtsColumn.HeaderText = "VName" dgtsColumn.Width = 100 dgtsStyle.GridColumnStyles.Add(dgtsColumn) dgtsColumn = New DataGridTextBoxColumn dgtsColumn.MappingName = "StartWeek" dgtsColumn.HeaderText = "Start" dgtsColumn.Width = 100 dgtsStyle.GridColumnStyles.Add(dgtsColumn) ' add the style to the datagrid dgridTarget.TableStyles.Add(dgtsStyle) ' open the connection connDB.Open() adapter.SelectCommand = New SqlCommand(sqlStmt, connDB) adapter.Fill(ds) dgridTarget.Visible = True dgridTarget.SetDataBinding(ds, "VendorsToCount") I need to use the Datagrid, because it is supported on the CF, where this app will be deployed. I am simply creating a dataset and binding it to the Datagrid. What am I missing here? Thanks for any help, WayneM =?Utf-8?B?V2F5bmVN?= <Way***@discussions.microsoft.com> wrote in
news:DD305AF7-0758-4E1B-94A7-0B72CED31BCE@microsoft.com: Slightly OT, but you should use SQLParameters to prevent a SQL injection > Dim sqlStmt As String = "Select VendorName, StartWeek from > InventorySchedule Where FinishDate is Null and StartWeek<'" & Now & > "'" attack.
That Eval Question Again...
Simple Eval() (Ithink) question gradient titlebar in vbdotnet Print the RichTextBox Updating Files How to return value in Combobox ListBox, ComboBox Bug??? NullReferenceException on DataGridView.Columns Index property .NET how to check binary compatability Naming convention of Variables |
|||||||||||||||||||||||