Ok, lo puse de esta manera y gracias a Dios si funcionó, haciendo referencia al botón ya funciona y es como
rikakashi me dijo al principio solo que yo tenia mal mi "selectedindex" así queda el código ya funcionando...
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
Private Sub list2(ByVal sender As Object, ByVal e As System.EventArgs)
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 cadena As String = lb1.SelectedItem.ToString()
Dim sql2 As String = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" & cadena & "' GROUP BY COLUMN_NAME"
Dim dr As New SqlCommand(sql2, conn)
conn.Open()
reader = dr.ExecuteReader()
While reader.Read()
values.Add(reader.Item("COLUMN_NAME").ToString())
End While
lb2.DataSource = values
lb2.DataBind()
reader.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:Button ID="Button1" runat="server" Text="Sirve" OnCommand="list2"
Width="71px"/>
<asp:Button ID="Button2" runat="server" style="margin-left: 82px"
Text="No Sirve" />
</form>
</body>
</html>
Muchas gracias!!!...