Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di mexican
    Registrato dal
    Oct 2001
    residenza
    cava de tirreni
    Messaggi
    3,541

    System.NullReferenceException: Riferimento a un oggetto non impostato su un'istanza d

    Ragazzi cosa vuol dire???
    Mi da l'errore dove ho messo una label.visible=true ed una false.
    ma che sbaglio?

    If stipo = "contraente" Then
    contraente.Visible = True
    proprietario.Visible = False
    Else
    contraente.Visible = False
    proprietario.Visible = True
    End If

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2002
    Messaggi
    4,127
    codice completo della pagina? grazie
    forse manca un New da qualche parte

  3. #3
    Utente di HTML.it L'avatar di mexican
    Registrato dal
    Oct 2001
    residenza
    cava de tirreni
    Messaggi
    3,541

    codice completo

    mports System.Data.OleDb
    Imports System.Configuration.ConfigurationSettings


    Public Class WebForm5
    Inherits System.Web.UI.Page

    Protected conn As OleDbConnection
    Protected cmdSql As OleDbCommand
    Protected strsql As String = ""
    Protected rs As OleDbDataReader
    Public snome As String, scognome As String, spiva As String, stipo As String
    Protected WithEvents lista As System.Web.UI.WebControls.Repeater
    Protected WithEvents nome As System.Web.UI.WebControls.TextBox
    Protected WithEvents cognome As System.Web.UI.WebControls.TextBox
    Protected WithEvents piva As System.Web.UI.WebControls.TextBox
    Protected WithEvents tipo As System.Web.UI.WebControls.DropDownList
    Protected WithEvents contraente As System.Web.UI.WebControls.Label
    Protected WithEvents proprietario As System.Web.UI.WebControls.Label




    Sub connetti()
    Dim strconn As String
    strconn = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" & Server.MapPath(".") & "\" & ConfigurationSettings.AppSettings("nomeDB")
    conn = New OleDbConnection(strconn)
    conn.Open()
    End Sub

    #Region " Codice generato da Progettazione Web Form "

    'Chiamata richiesta da Progettazione Web Form.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Protected WithEvents messaggio As System.Web.UI.WebControls.Label
    Protected WithEvents cerca As System.Web.UI.WebControls.Button

    'NOTA: la seguente dichiarazione è richiesta da Progettazione Web Form.
    'Non spostarla o rimuoverla.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    'CODEGEN: questa chiamata al metodo è richiesta da Progettazione Web Form.
    'Non modificarla nell'editor del codice.
    InitializeComponent()
    End Sub

    #End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Inserire qui il codice utente necessario per inizializzare la pagina
    If Request.QueryString("provenienza") = "dettaglio" Then
    connetti()
    'Try
    contraente.Visible = False
    proprietario.Visible = False
    BindLista(Request.QueryString("nome"), Request.QueryString("cognome"), Request.QueryString("piva"), Request.QueryString("tipo"))
    'Catch ex As Exception
    'messaggio.Text = "Errore: " & ex.Message()
    'Finally
    conn.Close()
    'End Try
    End If
    End Sub

    Private Sub cerca_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cerca.Click

    'Try
    snome = nome.Text
    scognome = cognome.Text
    spiva = piva.Text
    stipo = tipo.SelectedItem.Value
    BindLista(snome, scognome, spiva, stipo)

    'Catch ex As Exception
    'messaggio.Text = "Errore: " & ex.Message()

    'End Try
    End Sub
    Public Sub BindLista(ByVal snome As String, ByVal scognome As String, ByVal spiva As String, ByVal stipo As String)
    connetti()
    'Try
    strsql = "Select * from CLIENTI where"

    If stipo = "contraente" Then
    If snome <> "" Then
    strsql = strsql & " nome_c like '%" & Replace(snome, "'", "''") & "%' and"
    End If
    If scognome <> "" Then
    strsql = strsql & " cognome_c like '%" & Replace(scognome, "'", "''") & "%' and"
    End If
    If spiva <> "" Then
    strsql = strsql & " piva_c='" & Replace(spiva, "'", "''") & "' and"
    End If

    If Right(strsql, 5) = "where" Then
    strsql = Mid(strsql, 1, Len(strsql) - 5)
    End If
    If Right(strsql, 3) = "and" Then
    strsql = Mid(strsql, 1, Len(strsql) - 3)
    End If


    cmdSql = New OleDbCommand(strsql, conn)
    rs = cmdSql.ExecuteReader()
    lista.DataSource = rs
    lista.DataBind()
    rs.Close()

    Else
    If snome <> "" Then
    strsql = strsql & " nome_p like '%" & Replace(snome, "'", "''") & "%' and"
    End If
    If scognome <> "" Then
    strsql = strsql & " cognome_p like '%" & Replace(scognome, "'", "''") & "%' and"
    End If
    If spiva <> "" Then
    strsql = strsql & " piva_p='" & Replace(spiva, "'", "''") & "' and"
    End If

    If Right(strsql, 5) = "where" Then
    strsql = Mid(strsql, 1, Len(strsql) - 5)
    End If
    If Right(strsql, 3) = "and" Then
    strsql = Mid(strsql, 1, Len(strsql) - 3)
    End If


    cmdSql = New OleDbCommand(strsql, conn)
    rs = cmdSql.ExecuteReader()
    lista.DataSource = rs
    lista.DataBind()
    rs.Close()
    End If

    If stipo = "contraente" Then
    contraente.Visible = True
    'proprietario.Visible = False
    Else
    'contraente.Visible = False
    proprietario.Visible = True
    End If

    'Catch ex As Exception
    'messaggio.Text = "Errore: " & ex.Message()
    'Finally
    conn.Close()
    'End Try
    End Sub

    End Class

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 © 2025 vBulletin Solutions, Inc. All rights reserved.