Hola
rikakashi, disculpa por tardar tanto en contestar... Pues intente con el código que me hiciste el favor de postear, pero pues me sale este error:
No se puede indizar la clase 'System.Web.UI.WebControls.ListItem' porque no tiene ninguna propiedad predeterminada.
En esta línea:
De nuevo gracias por tu ayuda =)... Este es el código completo:
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"/>
<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" OnClick="list2"/>
<script language="vbscript" runat="server">
sub list2 (ByVal sender As Object, ByVal e As EventArgs)
Dim conn As SqlConnection =
New SqlConnection("server=myhost;database=mydb;User ID=myuser;Password=mypass;Trusted_Connection=no")
Dim cadena As String = ""
For i As Integer = 0 To lb1.Items.Count - 1
If lb1.SelectedItem(i) = True Then
If cadena = "" Then
cadena = "TABLE_NAME='" & lb1.SelectedItem(i).ToString & "'"
Else
cadena = cadena + (" OR TABLE_NAME='" & lb1.SelectedItem(i).ToString & "'")
End If
End If
Next
Dim sql2 As String = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE " & cadena & " GROUP BY COLUMN_NAME"
End Sub
</script>
</form>
</body>
</html>