daniel2milan
Member
- Joined
- Sep 3, 2005
- Messages
- 7
i have this code in order to customize datagrid but the header text wont appear n only return blank datagrid can some 1 help me?? is there any incorrect syntax on my code??
Code:
Public Function FillDataGrid(ByVal Sqlstring As String)
Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)
OleDbConn.Open()
Dim MyDataSet As DataSet = New DataSet
Dim MyOleDataAdapter As OleDbDataAdapter = New OleDbDataAdapter
MyOleDataAdapter.SelectCommand = New OleDbCommand(Sqlstring, OleDbConn)
MyOleDataAdapter.Fill(MyDataSet)
Dim tableStyle As New DataGridTableStyle
DataGrid1.DataSource = MyDataSet
tableStyle.MappingName = "usher"
Dim column1 As New DataGridTextBoxColumn
column1.MappingName = "userID"
column1.HeaderText = "User Name"
column1.Width = 30
tableStyle.GridColumnStyles.Add(column1)
Me.DataGrid1.DataSource = MyDataSet.Tables(0).DefaultView
Me.DataGrid1.TableStyles.Add(tableStyle)
For x As Integer = 0 To MyDataSet.Tables(0).Rows.Count - 1
ListBox1.Items.Add(MyDataSet.Tables(0).Rows(x).Item("Nama"))
Next
StatusBar1.Text = " " & MyDataSet.Tables(0).Rows.Count & " Rows."
MyOleDataAdapter.Dispose()
MyDataSet.Dispose()
OleDbConn.Close()
OleDbConn.Dispose()
If Not OleDbConn Is Nothing Then
OleDbConn.Close()
OleDbConn.Dispose()
End If
End Function