Hola
rikakashi gracias por tu respuesta. Pues lo coloque como dijiste, solo que agregue las variables del reader y la conexión en el evento del botón, pero el mismo resultado al darle clic a dicho botón, mi otro listbox sigue en blanco
... Aquí dejo el código por si me pudieran ayudar a resolver mi duda n_n... Gracias de nuevo...
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)
Dim reader As SqlDataReader
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 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 Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
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>
<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"/>
<asp:ListBox id="lb2" SelectionMode="Multiple" runat="server" Height="147px"
Width="196px"/>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>