W
wk6pack
Hi,
I have a datagrid that is populated from a query in SQL Server. The first
time I run the form, it appears, I make changes or view it and it is fine.
When I close the form and open it up again, the datagrid is not there to
see. I'm running the same code to populate it. What is happening? Any
suggestions?
thanks,
Will
Here is the code.
Dim ProcName As String = "PopulateDataGrid"
Dim daRoleDetail As SqlDataAdapter
Dim conn As SqlConnection
dsClass.Clear()
Me.dgClass.TableStyles.Clear()
Try
conn = New SqlConnection(UserInfoClass.sconn)
daRoleDetail = New SqlDataAdapter(SqlQuery, conn)
daRoleDetail.Fill(dsClass, TableName)
Dim ts As New DataGridTableStyle
ts.MappingName = TableName
ts.AlternatingBackColor = Color.WhiteSmoke
ts.SelectionBackColor = Color.Yellow
ts.SelectionForeColor = Color.Red
ts.PreferredRowHeight = 22
Dim colID As New DataGridTextBoxColumn
Dim colRoleDetail As New DataGridTextBoxColumn
Dim colclass As New DataGridTextBoxColumn
Call setDataGridProps(colID, "RoleDetailID", "ID", "", 75)
Call setDataGridProps(colRoleDetail, "RoleDetail", "Role Detail", "", 100)
Call setDataGridProps(colclass, "class", "Class", "", 200)
ts.GridColumnStyles.Add(colRoleDetail)
ts.GridColumnStyles.Add(colclass)
Me.dgClass.TableStyles.Add(ts)
ts = Nothing
Me.dgClass.SetDataBinding(dsClass, TableName)
Me.displayMsg(CStr(dsClass.Tables(TableName).Rows.Count) & " " & TableName &
" Records Loaded")
'clean up resources
If Not conn Is Nothing Then
conn.Close()
conn.Dispose()
End If
If Not daRoleDetail Is Nothing Then daRoleDetail.Dispose()
I have a datagrid that is populated from a query in SQL Server. The first
time I run the form, it appears, I make changes or view it and it is fine.
When I close the form and open it up again, the datagrid is not there to
see. I'm running the same code to populate it. What is happening? Any
suggestions?
thanks,
Will
Here is the code.
Dim ProcName As String = "PopulateDataGrid"
Dim daRoleDetail As SqlDataAdapter
Dim conn As SqlConnection
dsClass.Clear()
Me.dgClass.TableStyles.Clear()
Try
conn = New SqlConnection(UserInfoClass.sconn)
daRoleDetail = New SqlDataAdapter(SqlQuery, conn)
daRoleDetail.Fill(dsClass, TableName)
Dim ts As New DataGridTableStyle
ts.MappingName = TableName
ts.AlternatingBackColor = Color.WhiteSmoke
ts.SelectionBackColor = Color.Yellow
ts.SelectionForeColor = Color.Red
ts.PreferredRowHeight = 22
Dim colID As New DataGridTextBoxColumn
Dim colRoleDetail As New DataGridTextBoxColumn
Dim colclass As New DataGridTextBoxColumn
Call setDataGridProps(colID, "RoleDetailID", "ID", "", 75)
Call setDataGridProps(colRoleDetail, "RoleDetail", "Role Detail", "", 100)
Call setDataGridProps(colclass, "class", "Class", "", 200)
ts.GridColumnStyles.Add(colRoleDetail)
ts.GridColumnStyles.Add(colclass)
Me.dgClass.TableStyles.Add(ts)
ts = Nothing
Me.dgClass.SetDataBinding(dsClass, TableName)
Me.displayMsg(CStr(dsClass.Tables(TableName).Rows.Count) & " " & TableName &
" Records Loaded")
'clean up resources
If Not conn Is Nothing Then
conn.Close()
conn.Dispose()
End If
If Not daRoleDetail Is Nothing Then daRoleDetail.Dispose()