I had this page in my application working, but I requested my host company to move me to a new server where I can have remote DB access. All I should have had to do was change the connection string in the web.config. I am not sure if it is the code or the server. (Same setup: IIS7 .Net3.5 MSSQL 2005) Here is the code and the error page:
***********************************************ASPX***************************************************************
<%@ Page Language="C#" MasterPageFile="~/GNPM.Master" AutoEventWireup="true" CodeFile="ViewQuotes.aspx.cs" Inherits="GNP_Machining.Secure_Admin.WebForm2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="quote_no"
DataSourceID="ObjectDataSource1">
<Columns>
<asp:TemplateField HeaderText="Quote Number" InsertVisible="False"
SortExpression="quote_no">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("quote_no") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="ViewURL" runat="server" NavigateUrl='<%# FormatUrl( (int) Eval("quote_no") ) %>' Text = '<%# Eval("quote_no") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="create_datetime" HeaderText="Date"
SortExpression="create_datetime" />
<asp:BoundField DataField="update_user_id" HeaderText="User"
SortExpression="update_user_id" />
</Columns>
<HeaderStyle BackColor="#355532" ForeColor="White" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="Quote_Data_DatasetTableAdapters.Quote_FileTableAdapter"
UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_quote_no" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="user_id" Type="Object" />
<asp:Parameter Name="part_no" Type="String" />
<asp:Parameter Name="qty" Type="Int32" />
<asp:Parameter Name="est_due_date" Type="DateTime" />
<asp:Parameter Name="material_specs" Type="String" />
<asp:Parameter Name="instructions" Type="String" />
<asp:Parameter Name="create_user_id" Type="String" />
<asp:Parameter Name="create_datetime" Type="DateTime" />
<asp:Parameter Name="update_user_id" Type="String" />
<asp:Parameter Name="update_datetime" Type="DateTime" />
<asp:Parameter Name="Original_quote_no" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="user_id" Type="Object" />
<asp:Parameter Name="part_no" Type="String" />
<asp:Parameter Name="qty" Type="Int32" />
<asp:Parameter Name="est_due_date" Type="DateTime" />
<asp:Parameter Name="material_specs" Type="String" />
<asp:Parameter Name="instructions" Type="String" />
<asp:Parameter Name="create_user_id" Type="String" />
<asp:Parameter Name="create_datetime" Type="DateTime" />
<asp:Parameter Name="update_user_id" Type="String" />
<asp:Parameter Name="update_datetime" Type="DateTime" />
</InsertParameters>
</asp:ObjectDataSource>
</asp:Content>
***********************************************CodeBehind*********************************************************
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
namespace GNP_Machining.Secure_Admin
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlDataSource DataSource =(SqlDataSource)Page.FindControl("ObjectDataSource1");
}
}
protected string FormatUrl(int quote_no)
{
if (quote_no < 1)
throw new ArgumentOutOfRangeException("quote_no");return "ViewQuoteFiles.aspx?quote_no=" + quote_no;
}
}
}
***********************************************Error Page***********************************************************
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:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Quote_Data_DatasetTableAdapters.Quote_FileTableAdapter.InitConnection() +56
Quote_Data_DatasetTableAdapters.Quote_FileTableAdapter.InitAdapter() +462
Quote_Data_DatasetTableAdapters.Quote_FileTableAdapter.GetData() +22
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +308
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +480
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1960
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
|