99 messaggi dal 21 aprile 2007
provato...niente!sempre quel system byte finale


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>
<script language="C#" runat="server">
    
    //string TotalRecords = "Documenti trovati: ";

    SqlConnection myConnection;

    protected void Page_Load(Object Src, EventArgs E) 
    {
        myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\repository\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
        
        if (!IsPostBack) 
        {
            SqlDataAdapter myCommand = new SqlDataAdapter("select distinct categoria from tblCategory", myConnection);

            DataSet ds = new DataSet();
            myCommand.Fill(ds, "select");

            MySelect.DataSource= ds.Tables["select"].DefaultView;
            MySelect.DataBind();
        }
    }

    public void btnFiltra_Click(Object sender, EventArgs E)
    {
        String selectCmd = "select * from upload where cognome = @cognome and tipo = @Tipo UNION select * from upload where Titolo = @Titolo and tipo = @Tipo";
        SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\repository\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
        SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);
        
        myCommand.SelectCommand.Parameters.Add(new SqlParameter("@cognome", 2));
        myCommand.SelectCommand.Parameters["@cognome"].Value = tbFiltro.Text;
        myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Tipo", SqlDbType.VarChar, 50));
        myCommand.SelectCommand.Parameters["@Tipo"].Value = MySelect.Value;
        myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Titolo", SqlDbType.VarChar, 50));
        myCommand.SelectCommand.Parameters["@Titolo"].Value = MySelect.Value;


    }
    
    public void GetAuthors_Click(Object sender, EventArgs E) 
    {
        String selectCmd = "select * from upload where cognome = @cognome and tipo = @Tipo UNION select * from upload where Titolo = @Titolo and tipo = @Tipo";

        SqlConnection myConnection = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\repository\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
        SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);

        myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Tipo", SqlDbType.VarChar, 50));
        myCommand.SelectCommand.Parameters["@Tipo"].Value = MySelect.Value;
        
        myCommand.SelectCommand.Parameters.Add(new SqlParameter("@cognome", 2));
        myCommand.SelectCommand.Parameters["@cognome"].Value = tbFiltro.Text;

        myCommand.SelectCommand.Parameters.Add(new SqlParameter("@Titolo", 2));
        myCommand.SelectCommand.Parameters["@Titolo"].Value = tbFiltro.Text;
        
        DataSet ds = new DataSet();
        myCommand.Fill(ds, "upload");

        //TotalRecords += ds.Tables["upload"].Rows.Count.ToString();
        
        MyDataList.DataSource = ds.Tables["upload"].DefaultView;
        MyDataList.DataBind();
        messaggio.Text = "ricerca effettuata!";
    }

  
    

</script>

<head id="Head1" runat="server">
    <title>ricerca</title>
    <LINK href="mauro.css" rel=stylesheet>
    

    </head>
<body style="font: 10pt verdana">

  <form id="Form1" runat="server">
Immettere il nome autore pubblicazione <br/><br/>
<asp:TextBox id="tbFiltro" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server"
        ControlToValidate="tbFiltro"
        ErrorMessage="(*) Errore... immetere il nome dell'autore da cercare"
        ForeColor="Red">
    </asp:RequiredFieldValidator>

<BR><BR>

    scegli la categoria dove cercare<br/><br/>

    <select id="MySelect"  DataTextField="Categoria" runat="server" style="width: 122px" datavaluefield="Categoria"/>
    
    <input id="Submit1" type="submit" OnServerClick="GetAuthors_Click" Value="cerca" runat="server"/>
     <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server"
        ControlToValidate="MySelect"
        ErrorMessage="(*) Errore ... selezionare la categoria dove cercare!"
        ForeColor="Red">
    </asp:RequiredFieldValidator><p>

    <asp:label id="messaggio" runat="server" ForeColor="red" Font-Bold="True"></asp:label>&nbsp;
    
     <br /><br />
     
     <table style="WIDTH: 500px; BORDER-COLLAPSE: collapse" cellspacing="0" border="1">
     <tbody></tbody>
     </table>


<div style="OVERFLOW: auto; WIDTH: 40%; HEIGHT: 250px">
        <asp:DataList ID="MyDataList" 
             runat="server" 
             RepeatColumns="5"
             EnableViewState="False"
             
             RepeatLayout="Flow" Font-Bold="False" 
             Font-Italic="False" Font-Names="Verdana" 
             Font-Overline="False" Font-Strikeout="False"
             Font-Underline="False" Font-Size="Smaller">
            
            <ItemTemplate>
                
                
                <b>Autore:</b><br />
                <asp:Label ID="NomeLabel" runat="server" Width="100" Text='<%# Eval("Nome") %>'></asp:Label>
                <asp:Label ID="CognomeLabel" runat="server" Width="100"  Text='<%# Eval("Cognome") %>'></asp:Label><br />
                <b>Titolo Pubblicazione:</b>
                <b><i><font color="blue"">
                <asp:Label ID="TitoloLabel" runat="server" Width="450"  Text='<%# Eval("Titolo") %>'></asp:Label><br />
                </i></b></font>
                <b>Categoria:</b>
                <asp:Label ID="TipoLabel" runat="server" Width="100"  Text='<%# Eval("Tipo") %>'></asp:Label><br />
                <b>Abstract:</b><br />
                <asp:Label ID="AbstractLabel" runat="server" Width="400"  Text='<%# Eval("Abstract") %>'></asp:Label>
                <br />
                <b>ISBN:</b>
                <asp:Label ID="ISBNLabel" runat="server" Width="100"  Text='<%# Eval("ISBN") %>'></asp:Label>
                <b>ISNN:</b>
                <asp:Label ID="ISNNLabel" runat="server" Width="100"  Text='<%# Eval("ISNN") %>'></asp:Label><br />
                <b>documento:</b>
                <asp:Label ID="documentoLabel" runat="server" Width="100"  Text='<%# Eval("contenttype") %>'></asp:Label>
                <b>size:</b>
                <asp:Label ID="sizeLabel" runat="server" Width="100"  Text='<%# Eval("size") %>'></asp:Label><br />
                <b>download:</b>
                <asp:HyperLink ID="view" runat="server" Target=_blank
                 NavigateUrl='<%# "~/view_image.aspx?Doc_ID=" + DataBinder.Eval(Container.DataItem,"Doc_ID")+ Eval("documento").ToString() %>'
                 Text='<%# Eval("titolo") %>' /> <br />
                 
                <br />
                

            </ItemTemplate>
            
              
            
            <SeparatorStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                Font-Underline="False" BackColor="Black" ForeColor="Black" HorizontalAlign="Center" Wrap="False" />
            <ItemStyle BackColor="White" Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" />
        </asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:databaseConnectionString8 %>"
            SelectCommand="SELECT [Doc_ID], [Nome], [Cognome], [Dipartimento], [Titolo], [Data], [Tipo], [Keywords], [Abstract], [ISBN], [ISNN], [documento], [descrizione], [size], [contenttype] FROM [upload]">
        </asp:SqlDataSource>
        
       
       
  </form>

</body>
</html>
41 messaggi dal 19 febbraio 2007
Forse ho capito..
Nel codice
 NavigateUrl='<%# "~/view_image.aspx?Doc_ID=" + DataBinder.Eval(Container.DataItem,"Doc_ID")+ Eval("documento").ToString() %>'
Text='<%# Eval("titolo") %>' />


Devi togliere " + Eval("documento").ToString() ". Diventa così:

NavigateUrl='<%# "~/view_image.aspx?Doc_ID=" + DataBinder.Eval(Container.DataItem,"Doc_ID")%>'
Text='<%# DataBinder.Eval(Container.DataItem,"titolo") %>' />
99 messaggi dal 21 aprile 2007
mi da sempre errore :

Object reference not set to an instance of an object. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


Line 57:     Sub PDF()
Line 58: 
Line 59:         Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\tesi\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True").ConnectionString)
Line 60: 
Line 61:             Dim DocID As Integer = Convert.ToInt32(Request.QueryString("Doc_ID"))
 
Source File: C:\Inetpub\wwwroot\tesi\View_Document.aspx.vb    Line: 59 



in pratica mi da l'errore sulla connection string!
99 messaggi dal 21 aprile 2007
sembra che non veda il file nel databse..ma nel db c'è!bah
41 messaggi dal 19 febbraio 2007
L'errore è l'argomento che passi al costruttore dell'oggetto SqlConnection.
Prova così :

new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Inetpub\\wwwroot\\tesi\\App_Data\\database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
99 messaggi dal 21 aprile 2007
provato ma mi da un altro errore :


Instance failure. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Instance failure.

Source Error: 


Line 68:             Dim reader As SqlDataReader
Line 69: 
Line 70:             myConnection.Open()
Line 71:             reader = myCommand.ExecuteReader()
Line 72:             Do While reader.Read()
 

Source File: C:\Inetpub\wwwroot\tesi\View_Document.aspx.vb    Line: 70 


Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.