2

ボタン クリック イベントのコードは次のとおりです。

  Protected Sub CompetenciesButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CompetenciesButton.Click
        Dim con As String = WebConfigurationManager.ConnectionStrings("foo").ToString()
        Dim selectedrow As String = Competencies.SelectedValue.ToString
        Dim s As String = "SELECT * from foo WHERE (" & selectedrow & " =1)"
        Dim DataAdapter As New SqlDataAdapter(s, con)
        Dim Result As New DataTable
        If Not IsNothing(DataAdapter) Then
            DataAdapter.Fill(Result)
            DataAdapter.Dispose()
        End If
        GV.DataSource = Result
        GV.DataBind()
        GV2.DataSource = Result
        GV2.DataBind()
    End Sub

スタックは次のとおりです。

[NullReferenceException: Object reference not set to an instance of an object.]
   administration_Search.CompetenciesButton_Click(Object sender, EventArgs e) +28
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

VS2008 ではすべてオフラインで正常に動作しますが、公開後にこのエラーが発生します。

ありがとう。

4

1 に答える 1

1

WebConfiguration は、dev と live の両方で同じですか?

ライブ サーバーにfoo接続文字列がない場合、conオブジェクトは null に設定されます。

それでも問題をキャッチできない場合は、try/catch ブロックを含め、try のprogress外部で文字列変数を設定し、ロジック内のすべての行を更新して、現在の値とともにエラーをログに記録してみてくださいprogress。これは、発生している場所を絞り込むのに役立ちます。

于 2010-03-04T13:07:22.657 に答える