Gracias por tu respuesta
Aquaventus, mira lo intente sin el botón así:
Código ASP:
Ver original<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="vbscript" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
Dim values As ArrayList = New ArrayList()
Dim values2 As ArrayList = New ArrayList()
Dim conn As SqlConnection =
New SqlConnection("server=myhost;database=mydb;User ID=myuser;Password=mypass;Trusted_Connection=no")
Dim reader As SqlDataReader
Dim sql As String =
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_NAME"
Dim dr As New SqlCommand(sql, conn)
conn.Open()
reader = dr.ExecuteReader()
While reader.Read()
values.Add(reader.Item("TABLE_NAME").ToString())
End While
reader.Close()
DIM CADENA AS STRING = Convert.ToString(lb1.SELECTEDITEM)
Dim sql2 As String =
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME =' & CADENA & ' GROUP BY COLUMN_NAME"
Dim dr2 As New SqlCommand(sql2, conn)
reader = dr2.ExecuteReader()
While reader.Read()
values2.Add(reader.Item("COLUMN_NAME").ToString())
End While
lb1.DataSource = values
lb1.DataBind()
lb2.DataSource = values2
lb2.DataBind()
reader.Close()
conn.Close()
End If
End Sub
</script>
<html>
<head>
<title>Tablas y Columnas</title>
</head>
<body>
<asp:Label ID="Label1" runat="server" Text="RPE del Empleado"></asp:Label>
<form id="Form1" method="post" runat="server" name="ListEnlaza">
<asp:ListBox id="lb1" SelectionMode="Multiple" runat="server" Height="217px"
Width="196px" AutoPostBack="True"/>
<asp:ListBox id="lb2" SelectionMode="Multiple" runat="server" Height="147px"
Width="196px" AutoPostBack="True"/>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
Y cuando le daba clic al listbox2 me aparecía el dibujo del puntero del mouse cuando carga pero menos de un segundo y no me llenaba nada, intente habilitando el AutoPostBack para el list2, para el list1, para ambos y nada.... También lo intente con el botón, y nada:
Código ASP:
Ver original<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="vbscript" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
Dim reader As SqlDataReader
Dim values As ArrayList = New ArrayList()
Dim conn As SqlConnection =
New SqlConnection("server=myhost;database=mydb;User ID=myuser;Password=mypass;Trusted_Connection=no")
Dim sql As String =
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_NAME"
Dim dr As New SqlCommand(sql, conn)
conn.Open()
reader = dr.ExecuteReader()
While reader.Read()
values.Add(reader.Item("TABLE_NAME").ToString())
End While
lb1.DataSource = values
lb1.DataBind()
reader.Close()
End If
End Sub
</script>
<html>
<head>
<title>Tablas y Columnas</title>
</head>
<body>
<asp:Label ID="Label1" runat="server" Text="RPE del Empleado"></asp:Label>
<form id="Form1" method="post" runat="server" name="ListEnlaza">
<asp:ListBox id="lb1" SelectionMode="Multiple" runat="server" Height="217px"
Width="196px" AutoPostBack="True"/>
<asp:ListBox id="lb2" SelectionMode="Multiple" runat="server" Height="147px"
Width="196px" AutoPostBack="True"/>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="list2"/>
<script language="vbscript" runat="server">
sub list2 (ByVal sender As Object, ByVal e As EventArgs)
Dim reader As SqlDataReader
Dim values2 As ArrayList = New ArrayList()
Dim conn As SqlConnection =
New SqlConnection("server=myhost;database=mydb;User ID=myuser;Password=mypass;Trusted_Connection=no")
conn.Open()
DIM CADENA AS STRING = Convert.ToString(lb1.SELECTEDITEM)
Dim sql2 As String =
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME =' & CADENA & ' GROUP BY COLUMN_NAME"
Dim dr2 As New SqlCommand(sql2, conn)
reader = dr2.ExecuteReader()
While reader.Read()
values2.Add(reader.Item("COLUMN_NAME").ToString())
End While
lb2.DataSource = values2
lb2.DataBind()
reader.Close()
conn.Close()
End Sub
</script>
</form>
</body>
</html>
De nuevo gracias!!!...