473,563 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filling a DataGrid with a DataSet

I have compact framework app that I was trying to test out on a windows form,
but 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 InventorySchedu le
Where FinishDate is Null and StartWeek<'" & Now & "'"
Dim cmdDB As New SqlCommand(sqlS tmt, 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 DataGridTableSt yle
Dim dgtsColumn As DataGridTextBox Column
dgtsStyle = New DataGridTableSt yle

' set the tablestyle mapping to the table name
With dgtsStyle
.MappingName = "VendorsToCount "
End With

dgtsColumn = New DataGridTextBox Column
dgtsColumn.Mapp ingName = "VendorName "
dgtsColumn.Head erText = "VName"
dgtsColumn.Widt h = 100
dgtsStyle.GridC olumnStyles.Add (dgtsColumn)

dgtsColumn = New DataGridTextBox Column
dgtsColumn.Mapp ingName = "StartWeek"
dgtsColumn.Head erText = "Start"
dgtsColumn.Widt h = 100
dgtsStyle.GridC olumnStyles.Add (dgtsColumn)

' add the style to the datagrid
dgridTarget.Tab leStyles.Add(dg tsStyle)

' open the connection
connDB.Open()

adapter.SelectC ommand = New SqlCommand(sqlS tmt, connDB)
adapter.Fill(ds )

dgridTarget.Vis ible = True
dgridTarget.Set DataBinding(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
Sep 13 '06 #1
1 1585
=?Utf-8?B?V2F5bmVN?= <Wa****@discuss ions.microsoft. comwrote in
news:DD******** *************** ***********@mic rosoft.com:
Dim sqlStmt As String = "Select VendorName, StartWeek from
InventorySchedu le Where FinishDate is Null and StartWeek<'" & Now &
"'"
Slightly OT, but you should use SQLParameters to prevent a SQL injection
attack.

Sep 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3458
by: Hugo Lefevre | last post by:
dear, I have a form (frmlogonaccounts.cs) with a combobox, which I want to fill up with the first column of a dataset. The dataset is created in the class Login. My problem is the next : I make a new login in the form loginaccount which create a new login and give me a dataset (created by class login), which I can see in my datagrid. But I...
1
2198
by: Krzysztof Karnicki | last post by:
I have such a problem… I have create my custom DataGridColumn inheriting from System.Windows.Forms.DataGridColumnStyle on using it on DataGrid, to show rows painted by me self. Because dates taken from database are very large, and filling DataSet bounded to this DataGrid takes some time, a decided to put fill logic into new thread. And so...
2
1356
by: DC Gringo | last post by:
This code has two SELECT statements, each returning several records. I want to fill a dataset and then two datagrids. How would I fill the SECOND datagrid from this code ----- Sub BindSQL() Dim MyConnection As SqlConnection Dim DS as DataSet
3
1994
by: crjunk | last post by:
I have a 3 table in my DataSet that I'm filling with data. After I've filled these 3 tables, I'm then trying to run a query that will fill a 4th table in the DataSet with data from the three tables that are already pouplated. When my code tries to fill the 4th table, ReportData, I receive the following error message: Invalid object name...
1
2113
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). Both ASCXs have DataGrids on them. The first user control's DataGrid is populated from our database on page load. The DataGrid also has a Select...
4
10570
by: gillcleeren | last post by:
I have a datagrid that has to be filled in a WinForms application. The data comes from an Oracle database. The normal procedure would be filling a dataset, but I have the problem that there are over 100.000 records in the tables, so this has very low performance when executing. I then tried using an OracleDataReader, but for some reason,...
2
1354
by: savvy | last post by:
I'm trying to page a datagrid but the when i'm tying to fill the DataSet with a table, I know that using DataAdapter.Fill you can specify a single datatable to populate when the sp returns one table. How do I fill my dataset when the sp is a combination of two tables. i'm not able to understand how to fill it when i'm using a sql server...
4
1611
by: pintu | last post by:
Hi.. As we are assigning gridview's datasource to sqldatasource/dataset/datatabl­e..similarly is the reverse of this mechanism possible ?i.e. means get the displayed data from datagrid and fill another dataset with these data....Plz help in solving this problem.... Thanks Pintu
8
3056
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.