Solved

ado.Net - vb.net customised page using ASPEnterpriseManager.dll

Posted on 2009-07-16
6
183 Views
Last Modified: 2012-06-21
I am writting customised vb.net web-based pages and making use of ASPEnterpriseManager.dll The page references the dll to make the server connection. It lists all sql databse names with the following code.
For X = 0 To Server.Databases.Count - 1
Response.Write(Server.Databases(X))
Next
The question is that I want to list the db names in a repeater by adding the following.
If Items.Count <> 0 Then
Repeater1.DataSource = Server.Databases
Repeater1.DataBind()
It is not listing because I am not sure the following is correct in aspx page.
<%#Container.DataItem.ObjectName%>
The repeater is declared as follows:
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
I have a copy of the source code for the dll, if needed to be posted to help.
Thanks in advance.
'****************************************************
'app/cmsDataMenu.aspx.vb
'****************************************************
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Imports ASPEnterpriseManager
 
Namespace ASPEnterpriseManager.Pages
    
    Public Class cmsDataMenu
        Inherits System.Web.UI.Page
        Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
        Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
        ' initiate variables etc
        Public Source As DataView
        Public Ds As DataSet
        Sub Page_Load(ByVal Sender As System.Object, ByVal E As System.EventArgs)
            Dim _Context As HttpContext = HttpContext.Current
            If Not Page.IsPostBack Then
                Dim X As Integer
                Dim Y As Integer
                Dim Server As ASPEnterpriseManager.Server = New ASPEnterpriseManager.Server
                Dim Database As ASPEnterpriseManager.Database
                'Dim Roles As ASPEnterpriseManager.ServerRoles = New ASPEnterpriseManager.ServerRoles
                'Roles.Load()
                Server.LoadDatabases()
                'If ConnectionString.InitialCatalog <> "" Then
                Database = New ASPEnterpriseManager.Database
                Database.LoadObjects()
                Session("Database") = Database
                'End If
                Session("Server") = Server
                Dim messageLabel As String = "ConnectionString.InitialCatalog"
                Y = 0
                For X = 0 To Server.Databases.Count - 1
                    Y = Y + 1
                    Response.Write(Server.Databases(X))
                Next
                If Items.Count <> 0 Then
                    Repeater1.DataSource = Server.Databases
                    Repeater1.DataBind()
                End If
            End If
        End Sub
        Private Shared Shadows Sub Init()
            ' initiate variables etc
        End Sub
        Protected Sub testDatabase_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
 
        End Sub
    End Class
    
End Namespace
'****************************************************
'app/cmsDataMenu.aspx
'****************************************************
<%@ Page Language="VB" src="cmsDataMenu.aspx.vb" Inherits="ASPEnterpriseManager.Pages.cmsDataMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Sever Connection</title>
<style type="text/css">
</style>
</head>
<!--
Start Code Section
-->
<body style="background-image: url(images/WebFront.jpg); background-repeat:repeat-x">
<form id ="form1" runat="server">
<% if request("Sync") <> "true" then AppInterface.SyncLeftFrame() 
    'if ConnectionString.InitialCatalog <> "" then %>
<table id="table2" style="z-index:102; position:absolute; top:10px; left:10px; width:auto">
<tr>
<td>
<div style='width:550px; height:550px; overflow:auto; background: #ffffff; border: 1px solid #000000;'>
<h6>Heading:2:</h6>
<asp:Repeater id="Repeater1" runat="server">
      <HeaderTemplate>
          <table width="100%" cellpadding="2" cellspacing="0">
	          	<tr><td class="TableHeader">	          
						<h6>cmsDataMenu</h6>
					</td><td class="TableHeader">
						<h6>Description</h6>
					</td></tr>
      </HeaderTemplate>
      <ItemTemplate>
	          <tr ><td  class="TableGrid">
	          <%#Container.DataItem.ObjectName%>
	          </td><td  class="TableGrid">
	          
	          </td></tr>
      </ItemTemplate>
      <FooterTemplate>
          </table>
      </FooterTemplate>
	</asp:Repeater>
</div>
</td>
</tr>
</table>
<!--
End Code Section
-->
</form>
</body>
</html>

Open in new window

0
Comment
Question by:homeshopper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 500 total points
ID: 24870661
It would be nice that first take one Gridview control and bind Server.DataBases to GridView so it list down each column .
Then use that column name in Repeater control
0
 

Author Comment

by:homeshopper
ID: 24871019
Would it be possible to give an example using GridView?
I tried the following, but still not displaying database names.
DropDownList works in another page, but as you say,
it would be better to use GridView.
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="true">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
</Columns>
</asp:GridView>

 For X = 0 To Server.Databases.Count - 1
                    Response.Write(Server.Databases(X))
                    Y = Y + 1
                Next
                If Y <> 0 Then
                    GridView1.DataSource = Server.Databases
                    GridView1.DataBind()
                End If
The above gives the following error:
A field or property with the name 'Name' was not found on the selected data source. Line 57:                     GridView1.DataBind()
0
 

Author Comment

by:homeshopper
ID: 24871089
I have deleted <asp:BoundField DataField="Name" HeaderText="Name" />
it know works.
Just one more question, now it lists the db names, how can I
select an individual name and redirect to another gridview to display the tables contained in the selected database.
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Author Comment

by:homeshopper
ID: 24871231
I have the following code to try and display tables etc.
<%@ Page Language="VB" src="cmsData.aspx.vb" Inherits="ASPEnterpriseManager.Pages.cmsData" %>
<%@ Import Namespace="ASPEnterpriseManager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Sever Connection</title>
<style type="text/css">
</style>
</head>
<!--
Start Code Section
-->
<body style="background-image: url(images/WebFront.jpg); background-repeat:repeat-x">
<form id ="form1" runat="server">
<% if request("Sync") <> "true" then AppInterface.SyncLeftFrame()
    'if ConnectionString.InitialCatalog <> "" then %>
<table id="table2" style="z-index:102; position:absolute; top:10px; left:20px; width:auto">
<tr>
<td>
<div style='width:550px; height:140px; overflow:auto; background: #ffffff; border: 1px solid #000000;'>
<h6>Heading:2:</h6>
<% if request("Sync") <> "true" then AppInterface.SyncLeftFrame()
    'if ConnectionString.InitialCatalog <> "" then %>
                        <!--      
                        -->
                        <table>
                        <tr>
                        <td>
                         <img src="images/smallIcon_Database.gif" alt="" />
                         </td>
                         <td>
                         <h6>#<%= ConnectionString.InitialCatalog %>#</h6>
                         </td>
                         <td>
                        <a href="cmsData.aspx">&nbsp;Tables&nbsp;</a>
                        <a href="cmsViews.aspx">&nbsp;Views&nbsp;</a>
                        <a href="cmsStoredProcedures.aspx">&nbsp;Stored&nbsp;Procedures&nbsp;</a>
                        <a href="cmsUsers.aspx">&nbsp;Users&nbsp;</a>
                        <a href="cmsDatabaseRoles.aspx">&nbsp;DbRoles&nbsp;</a>
                        <!--
                        -->            
                <% 'Else%>
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;
                <% 'End If%>
                </td>
                </tr>
                </table>
</div>
</td>
</tr>
</table>
<table id="table3" style="z-index:103; position:absolute; top:160px; left:250px; width:auto">
<tr>
<td>
<div style='width:530px; height:350px; overflow:auto; background: #ffffff; border: 1px solid #000000;'>
<h6>Heading:3:</h6>
<asp:GridView id="GridView2" runat="server" AutoGenerateColumns="true">
<Columns>

</Columns>
</asp:GridView>
</div>
</td>
</tr>
</table>
<!--
End Code Section
-->
</form>
</body>
</html>
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Data.SqlClient
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports System.Data.OleDb
Imports ASPEnterpriseManager

Namespace ASPEnterpriseManager.Pages

    Public Class cmsData
        Inherits System.Web.UI.Page
        Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
        Protected WithEvents GridView2 As System.Web.UI.WebControls.GridView
        ' initiate variables etc
        Public Source As DataView
        Public Ds As DataSet
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' set tabel & database selectedIndexChange
            testDatabase_SelectedIndexChanged(DropDownList1, Nothing)
            If Not IsPostBack Then
                'Response.Write(":Selected:")
            End If
            Init()
        End Sub
        Private Shared Shadows Sub Init()
            ' initiate variables etc
        End Sub
        Protected Sub testDatabase_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            GridView2.DataSource = Session("Database").Tables
            GridView2.DataBind()
        End Sub

    End Class

End Namespace      
0
 

Author Comment

by:homeshopper
ID: 24871296
Should be as follows:
If Not IsPostBack Then
                'Response.Write(":Selected:")
GridView2.DataSource = Session("Database").Tables
            GridView2.DataBind()
End If
I can display system tables, but I would like to display only the
tables applicable to the selected database
0
 

Author Comment

by:homeshopper
ID: 24871672
In the first gridview I have added a select button:
<h6>Heading:2:</h6>
<asp:GridView id="GridView1" runat="server" Font-Size="XX-Small" AutoGenerateColumns="true">
<Columns>
<asp:ButtonField CommandName="Select" Text="Select"  />
</Columns>
</asp:GridView>
I want it to display selected db name in <h6>#<%= ConnectionString.InitialCatalog %>#</h6>
This is in code under heading:3:
I have 3 pages in total displaying in an iFrame for the default.aspx
I suspect that system tables and not selected tables in heading:4;
are displayed because the db name is not displayed in heading:3;
I hope the above is clear enough to understand me.
Thanks in advance.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question