OrderLine ordLine = new OrderLine();
//Load all the 'finalized' dummyLines into a datatable (this will be used to loop through and set parameters later)
dTab = DAL.GetAllDummyLinesForOrder(setRealOrderFromDummy);
foreach (DataRow row in dTab.Rows)
{
//'Get' values from the datable and use them to SET the values in the OrderLineClass
ordLine.OrderLineID = SqlInt32.Parse(dTab.Columns["OrderLineID"].ToString()); //Format Exception Being Thrown Here... WHY??
ordLine.OrderID = SqlInt32.Parse(dTab.Columns["OrderID"].ToString());
ordLine.ProductID = SqlInt32.Parse(dTab.Columns["ProductID"].ToString());
ordLine.Quantity = SqlInt32.Parse(dTab.Columns["Quantity"].ToString());
ordLine.LineValue = SqlMoney.Parse(dTab.Columns["LineValue"].ToString());
ordLine.VatID = SqlInt32.Parse(dTab.Columns["VatID"].ToString());
//Note IsActive is simply hardcoded
ordLine.IsActive = "Y";
//Add OrderLine With The Above Parameters
int x = DAL.AddOrderLine(ordLine);
}
Apologies for comments being messy, my ordLine is an instance class held in an external DLL. I have tried using:
ordLine.OrderLineID = SqlInt32.Parse(dTab.Rows[0].ToString());
as well with no success. I have checked the value of the datable dTab, and it does infact have rows and columns, so no error there right? The column names used in the foreach loop are the same as those in the SQL database, and thier datatypes match those of the class properties I am attempting to set. Even if i put in a try....catch the end result is these rows are not commited to my database.
Below is the code for the method DAL.AddOrderLine:
//Add Order Line
public int AddOrderLine(OrderLine orderLine)
{
using (SqlConnection dbConnection = new SqlConnection(DBConn))
{
int x;
SqlCommand dbCmd = new SqlCommand("uspAddOrderLine", dbConnection);
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.Parameters.AddWithValue("@orderLineID", orderLine.OrderLineID);
dbCmd.Parameters.AddWithValue("@orderID", orderLine.OrderID);
dbCmd.Parameters.AddWithValue("@productID", orderLine.ProductID);
dbCmd.Parameters.AddWithValue("@quantity", orderLine.Quantity);
dbCmd.Parameters.AddWithValue("@orderLineValue", orderLine.LineValue);
dbCmd.Parameters.AddWithValue("@vatID", orderLine.VatID);
dbCmd.Parameters.AddWithValue("@isActive", orderLine.IsActive);
try
{
if (dbConnection.State == ConnectionState.Closed)
{
dbConnection.Open();
}
x = dbCmd.ExecuteNonQuery();
}
catch (SqlException e)
{
exc = new Exceptions();
exc.Exception = e;
logExc = new LogException();
logExc.LogExceptionToFile();
throw new ApplicationException("Error occured in the database and / or connection");
}
//Realease Resources
dbConnection.Close();
dbConnection.Dispose();
dbCmd.Dispose();
return x;
}
}
this is contained in a class in another (seperate) DLL.
Any assistance will be appreciated, I hope I have given enough information

New Topic/Question
Reply



MultiQuote


I have stepped through it yes, I suspect its that value but I cant find it in locals? I have attached a screen snip on my debugger and how I am attempting to find the value of it in locals.



|