locked
Urgent help needed please RRS feed

  • Question

  • User2080995897 posted

    Hello experts....When i use the main database which is in the main server it works fine (almost) but when i bring the database into my local pc and attach it and use the database locally some functions work fine and some give this error...Could u guys plz tell me what the solution is? Below r the detail of the error generated:

    System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'Status'.
      at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
      at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
      at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
      at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
      at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
      at System.Data.SqlClient.SqlDataReader.get_MetaData()
      at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
      at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
      at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
      at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
      at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
      at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
      at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
      at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
      at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
      at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
      at LloydsDAL.DBManupulation.GetDataTable(String strSQL) in C:\lloyds\LloydsDAL\DBManipulation.cs:line 69 
    
    Source Error: 
    
    
    Line 2311:            strSQL += "where OrderNo is not null and OrderNo<>'' and O.OrderType='T' and O.IsJob=1 ORDER BY O.OrderID Desc";
    Line 2312:
    Line 2313:            dtblGenerateOrder = objDbManip.GetDataTable(strSQL);
    Line 2314:            gvBrowser.KeyFieldName = "OrderID";
    Line 2315:            gvBrowser.DataSource = (DataTable)dtblGenerateOrder;
     
    
    Source File: c:\Documents and Settings\aftabm\Desktop\LloydsOMS\LloydsOMS\WebForms\main.aspx.cs    Line: 2313 
    
    Stack Trace: 
    
    
    [Exception: System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'Status'.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
       at LloydsDAL.DBManupulation.GetDataTable(String strSQL) in C:\lloyds\LloydsDAL\DBManipulation.cs:line 69]
       LloydsDAL.DBManupulation.GetDataTable(String strSQL) in C:\lloyds\LloydsDAL\DBManipulation.cs:74
       WebForms_main.LoadGenerateTradeOrderData() in c:\Documents and Settings\aftabm\Desktop\LloydsOMS\LloydsOMS\WebForms\main.aspx.cs:2313
       WebForms_main.nbMenu_ItemClick(Object source, NavBarItemEventArgs e) in c:\Documents and Settings\aftabm\Desktop\LloydsOMS\LloydsOMS\WebForms\main.aspx.cs:769
       DevExpress.Web.ASPxNavBar.ASPxNavBar.OnItemClick(NavBarItemEventArgs e) +96
       DevExpress.Web.ASPxNavBar.ASPxNavBar.RaisePostBackEvent(String eventArgument) +541
       DevExpress.Web.ASPxClasses.ASPxWebControl.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
    
     
    
    
    Tuesday, June 14, 2011 5:12 AM

Answers

  • User-1516073966 posted

    hi,

    can you check the data base in main server is same as the local. I suspect that few of the tables are not.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 14, 2011 5:19 AM
  • User-1886250979 posted

    May be your local database and server database are mismatching. Check Status column in your local database.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 14, 2011 5:19 AM
  • User-269404413 posted

    Zehra,

    im sure, definately there is no column Status in the refering table, please check that.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 14, 2011 7:57 AM

All replies

  • User-1516073966 posted

    hi,

    can you check the data base in main server is same as the local. I suspect that few of the tables are not.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 14, 2011 5:19 AM
  • User-1886250979 posted

    May be your local database and server database are mismatching. Check Status column in your local database.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 14, 2011 5:19 AM
  • User-269404413 posted

    Zehar,

    'Status' this column is not found int the table but you are trying to access it so, you got this error. remove that and execute your query

    Tuesday, June 14, 2011 5:20 AM
  • User2080995897 posted

    but it is in the table....Ok the same database that is in the server it runs fine.... and doesnt give error but when i run the same database locally than it give this error

    Tuesday, June 14, 2011 5:50 AM
  • User2080995897 posted

    just in case this is the function coding....

     protected void LoadGenerateTradeOrderData()
        {
            DataTable dtblGenerateOrder = null;
            try
            {
                DeleteGridViewColumns();
    
                gvBrowser.DataSource = null;
                gvBrowser.Columns[0].Visible = true;
    
                CreateDataColumn(gvBrowser, "OrderID", "OrderID", 1, true, false);
                CreateDataColumn(gvBrowser, "Order No.", "OrderNo", 100, true, true);
                CreateDataColumn(gvBrowser, "Order Date", "OrderDate", 50, true, true);
                CreateDataColumn(gvBrowser, "Customer Name", "CustomerName", 200, true, true);
    
                CreateDataColumn(gvBrowser, "Phone", "Phone", 100, true, true);
                CreateDataColumn(gvBrowser, "Quotation Reference", "QuotationReference", 100, true, true);
                CreateDataColumn(gvBrowser, "Value", "OrderValue", 100, true, true);
                CreateDataColumn(gvBrowser, "VAT", "VatAmt", 100, true, true);
                CreateDataColumn(gvBrowser, "Grand Total", "SaleValue", 100, true, true);
                CreateDataColumn(gvBrowser, "Status", "Status", 50, true, true);
    
                string strSQL = "Select O.OrderID,O.Status,O.OrderNo, Convert(varchar(10),O.OrderDate,103) as OrderDate,O.QuotationReference, ";
                strSQL += "Convert(varchar(10),O.DeliveryDate,103) as DeliveryDate,O.OrderValue,O.VatAmt,O.SaleValue, ";
                strSQL += "C.CustomerName,C.ResPhoneNo as Phone ";
                strSQL += "FROM [ORDER] O inner JOIN Customer C on O.CustomerID=C.CustomerID ";
                strSQL += "where OrderNo is not null and OrderNo<>'' and O.OrderType='T' and O.IsJob=1 ORDER BY O.OrderID Desc";
    
                dtblGenerateOrder = objDbManip.GetDataTable(strSQL);
                gvBrowser.KeyFieldName = "OrderID";
                gvBrowser.DataSource = (DataTable)dtblGenerateOrder;
                gvBrowser.DataBind();
    
                gvBrowser.Settings.ShowFilterRow = true;
                gvBrowser.Settings.ShowGroupPanel = true;
                gvBrowser.FocusedRowIndex = 0;
                gvBrowser.SettingsBehavior.AllowFocusedRow = true;
            }
            finally
            {
                if (dtblGenerateOrder != null) dtblGenerateOrder.Dispose();
            }
        }
    Tuesday, June 14, 2011 5:58 AM
  • User-1516073966 posted

    Hi

    From the above code, the CreateDataColumn will create columns in grid vew right?

    Does OrderTable has the Status column?

    Once check the order table.

    Tuesday, June 14, 2011 6:57 AM
  • User2080995897 posted

    no it has StatusID not Status......But i wonder the same database which is used in the main server runs perfectly fine...why is that? what should i do now? but tell me step by step coz i dont know much :-)

    Tuesday, June 14, 2011 7:03 AM
  • User-1516073966 posted

    Try it out the following code, Since the Order table do not have the status column its giving error. As you said its not status i have changed it to StatusId and modified the code is below.

    protected void LoadGenerateTradeOrderData()
        {
            DataTable dtblGenerateOrder = null;
            try
            {
                DeleteGridViewColumns();
    
                gvBrowser.DataSource = null;
                gvBrowser.Columns[0].Visible = true;
    
                CreateDataColumn(gvBrowser, "OrderID", "OrderID", 1, true, false);
                CreateDataColumn(gvBrowser, "Order No.", "OrderNo", 100, true, true);
                CreateDataColumn(gvBrowser, "Order Date", "OrderDate", 50, true, true);
                CreateDataColumn(gvBrowser, "Customer Name", "CustomerName", 200, true, true);
    
                CreateDataColumn(gvBrowser, "Phone", "Phone", 100, true, true);
                CreateDataColumn(gvBrowser, "Quotation Reference", "QuotationReference", 100, true, true);
                CreateDataColumn(gvBrowser, "Value", "OrderValue", 100, true, true);
                CreateDataColumn(gvBrowser, "VAT", "VatAmt", 100, true, true);
                CreateDataColumn(gvBrowser, "Grand Total", "SaleValue", 100, true, true);
                CreateDataColumn(gvBrowser, "StatusID", "StatusID", 50, true, true);
    
                string strSQL = "Select O.OrderID,O.StatusID,O.OrderNo, Convert(varchar(10),O.OrderDate,103) as OrderDate,O.QuotationReference, ";
                strSQL += "Convert(varchar(10),O.DeliveryDate,103) as DeliveryDate,O.OrderValue,O.VatAmt,O.SaleValue, ";
                strSQL += "C.CustomerName,C.ResPhoneNo as Phone ";
                strSQL += "FROM [ORDER] O inner JOIN Customer C on O.CustomerID=C.CustomerID ";
                strSQL += "where OrderNo is not null and OrderNo<>'' and O.OrderType='T' and O.IsJob=1 ORDER BY O.OrderID Desc";
    
                dtblGenerateOrder = objDbManip.GetDataTable(strSQL);
                gvBrowser.KeyFieldName = "OrderID";
                gvBrowser.DataSource = (DataTable)dtblGenerateOrder;
                gvBrowser.DataBind();
    
                gvBrowser.Settings.ShowFilterRow = true;
                gvBrowser.Settings.ShowGroupPanel = true;
                gvBrowser.FocusedRowIndex = 0;
                gvBrowser.SettingsBehavior.AllowFocusedRow = true;
            }
            finally
            {
                if (dtblGenerateOrder != null) dtblGenerateOrder.Dispose();
            }
        }
    Tuesday, June 14, 2011 7:14 AM
  • User2080995897 posted

    dear Chandrashekar i have tried putting the StatusID instead of that......it did work that way but u know the company want Status to be there. not StatusID.....Beside when the same database is used in the main server how is that accepting the value Status there?

    Tuesday, June 14, 2011 7:33 AM
  • User-269404413 posted

    Zehra,

    im sure, definately there is no column Status in the refering table, please check that.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 14, 2011 7:57 AM