Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Problema Connessione DB

    Ciao a tutti,
    ho creato questa pagina .aspx che dovrebbe collegarsi al BD NORTHWIND di sql server installato sul mio pc locale.
    La cosa strana che non mi da nessun errore ma non mi visualizza nulla sulla pagina.
    Potete aiutarmi??
    Grazie
    spider81man

    ECCO IL CODICE DELLA PAGINA ASPX:

    <%@ Import Namespace="System.Data.OleDb" %>
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="connessione2.WebForm1"%>
    <HTML>
    <script runat="server">
    sub Page_Load
    dim dbconn,sql,dbcomm,dbread
    dbconn=New OleDbConnection("Data Source=localhost;Initial Catalog=Northwind;User ID=sa;Password=XXX;Persist Security Info=True;")
    dbconn.Open()
    sql="SELECT * FROM customers"
    dbcomm=New OleDbCommand(sql,dbconn)
    dbread=dbcomm.ExecuteReader()
    customers.DataSource=dbread
    customers.DataBind()
    dbread.Close()
    dbconn.Close()
    end sub
    </script>



    <body>
    <form runat="server" ID="Form1">
    <asp:Repeater id="customers" runat="server">
    <HeaderTemplate>
    <table border="1" width="100%">
    <tr>
    <th>
    Nome Compagnia</th>
    <th>
    Nome Contatto</th>
    <th>
    Indirizzo</th>
    <th>
    Città</th>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td><%#Container.DataItem("companyname")%></td>
    <td><%#Container.DataItem("contactname")%></td>
    <td><%#Container.DataItem("address")%></td>
    <td><%#Container.DataItem("city")%></td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </asp:Repeater>
    </form>
    </body>
    </HTML>

  2. #2
    Mi hanno detto di modifica re in questo modo ma il problema rimane:

    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="connessione2.WebForm1"%>
    <HTML>
    <script runat="server">
    sub Page_Load
    Dim dbconn As SqlConnection
    Dim dbcomm As SqlCommand
    Dim dbread As SqlDataReader
    Dim sql As String

    dbconn=New SqlConnection("Data Source=localhost;Initial Catalog=Northwind;User ID=sa;Password=XXX;Persist Security Info=True;")
    dbconn.Open()
    sql="SELECT * FROM customers"
    dbcomm=New SqlCommand(sql,dbconn)
    dbread=dbcomm.ExecuteReader()
    customers.DataSource=dbread
    customers.DataBind()
    dbread.Close()
    dbconn.Close()
    end sub
    </script>



    <body>
    <form runat="server" ID="Form1">
    <asp:Repeater id="customers" runat="server">
    <HeaderTemplate>
    <table border="1" width="100%">
    <tr>
    <th>
    Nome Compagnia</th>
    <th>
    Nome Contatto</th>
    <th>
    Indirizzo</th>
    <th>
    Città</th>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td><%#Container.DataItem("companyname")%></td>
    <td><%#Container.DataItem("contactname")%></td>
    <td><%#Container.DataItem("address")%></td>
    <td><%#Container.DataItem("city")%></td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </asp:Repeater>
    </form>
    </body>
    </HTML>

    HELP!!!!

  3. #3
    Risolto ecco come:
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Page Language="vb"%>

    <script runat="server">
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim dbconn As SqlConnection
    Dim dbcomm As SqlCommand
    Dim dbread As SqlDataReader
    Dim sql As String
    Dim sql1 As String

    dbconn = New SqlConnection("Data Source=localhost; Initial Catalog=Northwind; User ID=sa;Password=cisco1981;")
    dbconn.Open()
    sql = "SELECT * FROM customers"
    dbcomm = New SqlCommand(sql,dbconn)
    dbread = dbcomm.ExecuteReader()
    customers.DataSource = dbread
    customers.DataBind()
    dbread.Close()
    dbconn.Close()

    End Sub
    </script>

    <html>
    <body>
    <form runat="server" ID="Form1">
    <asp:Repeater id="customers" runat="server">
    <HeaderTemplate>
    <table border="1" width="100%">
    <tr>
    <th>
    Nome Compagnia</th>
    <th>
    Nome Contatto</th>
    <th>
    Indirizzo</th>
    <th>
    Città</th>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td><%#Container.DataItem("companyname")%></td>
    <td><%#Container.DataItem("contactname")%></td>
    <td><%#Container.DataItem("address")%></td>
    <td><%#Container.DataItem("city")%></td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </asp:Repeater>
    </form>
    </body>
    </html>

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    4,127
    hai tolto solo
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="connessione2.WebForm1"%>
    ? o sbaglio?

    nn è conveniente fare un misto tra codebehind e codice inline..
    cmq censura la password

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.