Solved

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

Posted on 2009-07-16
6
181 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
  • 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help making a program or form for inventory that exports to txt 8 39
imap read mail 1 27
asp enable view state 1 24
Store results in vb.net 3 20
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

786 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