I am getting this error: "Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails." --But my value is not null. I did a response.write on it and it show the value. Of course, it would be nice if I could do a breakpoint but that doesn't seem to be working. I'll attach a couple of images below of my code, the error, and the breakpoint error.
Server Error in '/' Application.
Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails.
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.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails.
Source Error:
Line 89: sContact.Phone = sPhone.Text.TrimLine 90: sContact.Email = sEmail.Text.TrimLine 91: sContact.Save()Line 92: Line 93: Dim bContact As Contact = New Contact()
Source File:F:\Inetpub\wwwroot\Outman Knife\Checkout.aspx.vb Line:91
Stack Trace:
[SqlException (0x80131904): Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838 System.Data.SqlClient.SqlDataReader.HasMoreRows() +150 System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +214 System.Data.SqlClient.SqlDataReader.Read() +9 System.Data.SqlClient.SqlCommand.CompleteExecuteScalar(SqlDataReader ds, Boolean returnSqlValue) +39 System.Data.SqlClient.SqlCommand.ExecuteScalar() +148 SubSonic.SqlDataProvider.ExecuteScalar(QueryCommand qry) +209 SubSonic.DataService.ExecuteScalar(QueryCommand cmd) +37 SubSonic.ActiveRecord`1.Save(String userName) +120 SubSonic.ActiveRecord`1.Save() +31 Checkout.btnCheckout_Click(Object sender, EventArgs e) in F:\Inetpub\wwwroot\Outman Knife\Checkout.aspx.vb:91 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) +5102
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
Please post the code of the Save method of your Contact class, the stored procedure that it calls and the table definition.|||I am using SubSonic, so I am not sure how I would do this. Here is the entire Contact class:
1Imports System2Imports System.Text3Imports System.Data4Imports System.Data.SqlClient5Imports System.Data.Common6Imports System.Collections7Imports System.Collections.Generic8Imports System.Configuration9Imports System.Xml10Imports System.Xml.Serialization11Imports SubSonic12131415''' <summary>16''' Strongly-typed collection for the Contact class.17''' </summary>18<Serializable> _19Public PartialClass ContactCollection20Inherits ActiveList(Of Contact)2122Private wheresAs List(Of Where) =New List(Of Where)()23Private betweensAs List(Of BetweenAnd) =New List(Of BetweenAnd)()24Private orderByAs SubSonic.OrderBy25Public Function OrderByAsc(ByVal columnNameAs String)As ContactCollection26Me.orderBy = SubSonic.OrderBy.Asc(columnName)27Return Me28 End Function29 Public Function OrderByDesc(ByVal columnNameAs String)As ContactCollection30Me.orderBy = SubSonic.OrderBy.Desc(columnName)31Return Me32 End Function33 Public Function WhereDatesBetween(ByVal columnNameAs String,ByVal dateStartAs DateTime,ByVal dateEndAs DateTime)As ContactCollection34Return Me3536 End Function3738 Public Function Where(ByVal where_RenamedAs Where)As ContactCollection39 wheres.Add(where_Renamed)40Return Me41 End Function42 Public Function Where(ByVal columnNameAs String,ByVal valueAs Object)As ContactCollection43Dim where_RenamedAs Where =New Where()44 where_Renamed.ColumnName = columnName45 where_Renamed.ParameterValue = value46Me.Where(where_Renamed)47Return Me48 End Function49 Public Function Where(ByVal columnNameAs String,ByVal compAs Comparison,ByVal valueAs Object)As ContactCollection50Dim where_RenamedAs Where =New Where()51 where_Renamed.ColumnName = columnName52 where_Renamed.Comparison = comp53 where_Renamed.ParameterValue = value54Me.Where(where_Renamed)55Return Me5657 End Function58 Public Function BetweenAnd(ByVal columnNameAs String,ByVal dateStartAs DateTime,ByVal dateEndAs DateTime)As ContactCollection59Dim betweenAs BetweenAnd =New BetweenAnd()60 between.ColumnName = columnName61 between.StartDate = dateStart62 between.EndDate = dateEnd63 betweens.Add(between)64Return Me65 End Function66 Public Overloads Function Load()As ContactCollection6768Dim qryAs Query =New Query("Contact")69For Each whereAs WhereIn wheres70 qry.AddWhere(where)71Next72 For Each betweenAs BetweenAndIn betweens73 qry.AddBetweenAnd(between)74Next7576 If Not orderByIs Nothing Then77 qry.OrderBy = orderBy78End If7980 Dim rdrAs IDataReader = qry.ExecuteReader()81Me.Load(rdr)82 rdr.Close()8384Return Me85 End Function8687Public Overloads Function Load(ByVal qryAs Query)As ContactCollection8889Dim rdrAs IDataReader = qry.ExecuteReader()90Me.Load(rdr)91 rdr.Close()9293Return Me94 End Function9596 Public Sub New()979899End Sub100101End Class102103''' <summary>104''' This is an ActiveRecord class which wraps the Contact table.105''' </summary>106<Serializable> _107Public PartialClass Contact108Inherits ActiveRecord(Of Contact)109110#Region"Default Settings"111Private Sub SetSQLProps()112If SchemaIs Nothing Then113 Schema = Query.BuildTableSchema("Contact")114End If115 End Sub116 #End Region117118 #Region"Schema Accessor"119Public Shared Function GetTableSchema()As TableSchema.Table120Dim itemAs Contact =New Contact()121Return Contact.Schema122End Function123 #End Region124125 #Region"Query Accessor"126Public Shared Function CreateQuery()As Query127Return New Query("Contact")128End Function129 #End Region130131 #Region".ctors"132Public Sub New()133 SetSQLProps()134 SetDefaults()135Me.MarkNew()136End Sub137138 Public Sub New(ByVal keyIDAs Object)139 SetSQLProps()140MyBase.LoadByKey(keyID)141End Sub142143 Public Sub New(ByVal columnNameAs String,ByVal columnValueAs Object)144 SetSQLProps()145MyBase.LoadByParam(columnName,columnValue)146End Sub147 #End Region148149 #Region"Public Properties"150 <XmlAttribute("OrderID")> _151Public Property OrderIDAs Guid152Get153 Dim resultAs Object =Me.GetColumnValue("OrderID")154Dim oOutAs Guid=Guid.Empty155Try156oOut=New Guid(result.ToString())157Catch158End Try159 Return oOut160161End Get162 Set163 Me.MarkDirty()164Me.SetColumnValue("OrderID", Value)165End Set166 End Property167 <XmlAttribute("Type")> _168Public Property TypeAs String169 Get170 Dim resultAs Object =Me.GetColumnValue("Type")171Dim sOutAs String172 If resultIs Nothing Then : sOut =String.Empty173Else : sOut = result.ToString()174End If175 Return sOut176177End Get178 Set179 Me.MarkDirty()180Me.SetColumnValue("Type", Value)181End Set182 End Property183 <XmlAttribute("LastName")> _184Public Property LastNameAs String185 Get186 Dim resultAs Object =Me.GetColumnValue("LastName")187Dim sOutAs String188 If resultIs Nothing Then : sOut =String.Empty189Else : sOut = result.ToString()190End If191 Return sOut192193End Get194 Set195 Me.MarkDirty()196Me.SetColumnValue("LastName", Value)197End Set198 End Property199 <XmlAttribute("FirstName")> _200Public Property FirstNameAs String201 Get202 Dim resultAs Object =Me.GetColumnValue("FirstName")203Dim sOutAs String204 If resultIs Nothing Then : sOut =String.Empty205Else : sOut = result.ToString()206End If207 Return sOut208209End Get210 Set211 Me.MarkDirty()212Me.SetColumnValue("FirstName", Value)213End Set214 End Property215 <XmlAttribute("Company")> _216Public Property CompanyAs String217 Get218 Dim resultAs Object =Me.GetColumnValue("Company")219Dim sOutAs String220 If resultIs Nothing Then : sOut =String.Empty221Else : sOut = result.ToString()222End If223 Return sOut224225End Get226 Set227 Me.MarkDirty()228Me.SetColumnValue("Company", Value)229End Set230 End Property231 <XmlAttribute("Address")> _232Public Property AddressAs String233 Get234 Dim resultAs Object =Me.GetColumnValue("Address")235Dim sOutAs String236 If resultIs Nothing Then : sOut =String.Empty237Else : sOut = result.ToString()238End If239 Return sOut240241End Get242 Set243 Me.MarkDirty()244Me.SetColumnValue("Address", Value)245End Set246 End Property247 <XmlAttribute("City")> _248Public Property CityAs String249 Get250 Dim resultAs Object =Me.GetColumnValue("City")251Dim sOutAs String252 If resultIs Nothing Then : sOut =String.Empty253Else : sOut = result.ToString()254End If255 Return sOut256257End Get258 Set259 Me.MarkDirty()260Me.SetColumnValue("City", Value)261End Set262 End Property263 <XmlAttribute("StateID")> _264Public Property StateIDAs Integer265 Get266 Dim resultAs Object =Me.GetColumnValue("StateID")267Dim oOutAs Integer = 0268Try269oOut =Integer.Parse(result.ToString())270Catch271End Try272 Return oOut273274End Get275 Set276 Me.MarkDirty()277Me.SetColumnValue("StateID", Value)278End Set279 End Property280 <XmlAttribute("ZipCode")> _281Public Property ZipCodeAs Integer282 Get283 Dim resultAs Object =Me.GetColumnValue("ZipCode")284Dim oOutAs Integer = 0285Try286oOut =Integer.Parse(result.ToString())287Catch288End Try289 Return oOut290291End Get292 Set293 Me.MarkDirty()294Me.SetColumnValue("ZipCode", Value)295End Set296 End Property297 <XmlAttribute("Phone")> _298Public Property PhoneAs String299 Get300 Dim resultAs Object =Me.GetColumnValue("Phone")301Dim sOutAs String302 If resultIs Nothing Then : sOut =String.Empty303Else : sOut = result.ToString()304End If305 Return sOut306307End Get308 Set309 Me.MarkDirty()310Me.SetColumnValue("Phone", Value)311End Set312 End Property313 <XmlAttribute("Email")> _314Public Property EmailAs String315 Get316 Dim resultAs Object =Me.GetColumnValue("Email")317Dim sOutAs String318 If resultIs Nothing Then : sOut =String.Empty319Else : sOut = result.ToString()320End If321 Return sOut322323End Get324 Set325 Me.MarkDirty()326Me.SetColumnValue("Email", Value)327End Set328 End Property329330 #End Region331332 #Region"ObjectDataSource support"333''' <summary>334 ''' Inserts a record, can be used with the ObjectDataSource335 ''' </summary>336Public Shared Sub Insert(ByVal OrderIDAs Guid,ByVal TypeAs String,ByVal LastNameAs String,ByVal FirstNameAs String,ByVal CompanyAs String,ByVal AddressAs String,ByVal CityAs String,ByVal StateIDAs Integer,ByVal ZipCodeAs Integer,ByVal PhoneAs String,ByVal EmailAs String)337Dim itemAs Contact =New Contact()338 item.OrderID = OrderID339item.Type = Type340item.LastName = LastName341item.FirstName = FirstName342item.Company = Company343item.Address = Address344item.City = City345item.StateID = StateID346item.ZipCode = ZipCode347item.Phone = Phone348item.Email = Email349350 item.Save(System.Web.HttpContext.Current.User.Identity.Name)351End Sub352353''' <summary>354 ''' Updates a record, can be used with the ObjectDataSource355 ''' </summary>356Public Shared Sub Update(ByVal OrderIDAs Guid,ByVal TypeAs String,ByVal LastNameAs String,ByVal FirstNameAs String,ByVal CompanyAs String,ByVal AddressAs String,ByVal CityAs String,ByVal StateIDAs Integer,ByVal ZipCodeAs Integer,ByVal PhoneAs String,ByVal EmailAs String)357Dim itemAs Contact =New Contact()358 item.OrderID = OrderID359item.Type = Type360item.LastName = LastName361item.FirstName = FirstName362item.Company = Company363item.Address = Address364item.City = City365item.StateID = StateID366item.ZipCode = ZipCode367item.Phone = Phone368item.Email = Email369370 item.IsNew =False371 item.Save(System.Web.HttpContext.Current.User.Identity.Name)372End Sub373374 #End Region375376 #Region"Columns Struct"377Public Structure Columns378Public Shared OrderIDAs String379Public Shared TypeAs String380Public Shared LastNameAs String381Public Shared FirstNameAs String382Public Shared CompanyAs String383Public Shared AddressAs String384Public Shared CityAs String385Public Shared StateIDAs String386Public Shared ZipCodeAs String387Public Shared PhoneAs String388Public Shared EmailAs String389Private xAs Integer390391392 Shared Sub New()393 OrderID ="OrderID"394Type ="Type"395LastName ="LastName"396FirstName ="FirstName"397Company ="Company"398Address ="Address"399City ="City"400StateID ="StateID"401ZipCode ="ZipCode"402Phone ="Phone"403Email ="Email"404405End Sub406 End Structure407 #End Region408409End Class410411|||It looks like the save method is down yet another level. Search on item.Save in the class you just posted, highlight where the Save, right-click and goto to the definition. I need to see the save and the stored procedure it calls.|||
Hopefully this has what you are looking for:
1using System;2using System.Data;3using SubSonic.Utilities;4using System.Text;5namespace SubSonic6{78public abstract class ActiveRecord : AbstractRecord where T : AbstractRecord,new()9 {10public ActiveRecord()11 {12 MarkNew();13 }1415#region CommandMethods1617/// <summary>18 /// Made Public for use with transactions19 /// </summary>20 /// <param name="userName"></param>21 /// <returns></returns>22public QueryCommand GetInsertCommand(string userName)23 {24 Query q =new Query(table);25 q.QueryType = QueryType.Insert;26 QueryCommand cmd =new QueryCommand(DataService.GetSql(q));2728//loop the Columns and addin the params2930foreach (TableSchema.TableColumn columnin table.Columns)31 {32if (!column.AutoIncrement)33 {34object oVal;35if (Utility.IsMatch(column.ColumnName, ReservedColumnName.CREATED_BY) || Utility.IsMatch(column.ColumnName, ReservedColumnName.MODIFIED_BY))36 {37 oVal = userName;38 }39else if (Utility.IsMatch(column.ColumnName, ReservedColumnName.CREATED_ON) || Utility.IsMatch(column.ColumnName, ReservedColumnName.MODIFIED_ON))40 {41 oVal = DateTime.Now;42 }43else44 {45 oVal = GetColumnValue(column.ColumnName);4647//if the value is a boolean, it can be read improperly48 //reset to 0 or 149if (oVal !=null)50 {51if (Utility.IsMatch(oVal.ToString(),"false"))52 {53 oVal = 0;54 }55else if (Utility.IsMatch(oVal.ToString(),"true"))56 {57 oVal = 1;58 }59 }60 }61if (oVal ==null)62 {63 oVal = DBNull.Value;64 }65 cmd.Parameters.Add("@." + column.ColumnName, oVal, column.DataType);66 }67 }68return cmd;69 }7071public QueryCommand GetUpdateCommand(string userName)72 {73 Query q =new Query(table);74 q.QueryType = QueryType.Update;75 QueryCommand cmd =new QueryCommand(DataService.GetSql(q));7677//loop the Columns and addin the params78foreach (TableSchema.TableColumn columnin table.Columns)79 {80object oVal;81if (Utility.IsMatch(column.ColumnName, ReservedColumnName.MODIFIED_BY))82 {83 oVal = userName;84 }85else if (Utility.IsMatch(column.ColumnName, ReservedColumnName.MODIFIED_ON))86 {87 oVal = DateTime.Now;88 }89else90 {91 oVal = GetColumnValue(column.ColumnName);92 }93if (oVal ==null)94 {95 oVal = DBNull.Value;96 }97 cmd.Parameters.Add("@." + column.ColumnName, oVal,column.DataType);98 }99return cmd;100 }101102public static QueryCommand GetDeleteCommand(object keyID)103 {104 Query q =new Query(table);105 q.QueryType = QueryType.Delete;106 q.AddWhere(table.PrimaryKey.ColumnName, keyID);107108return DataService.BuildCommand(q);109 }110111public static QueryCommand GetDeleteCommand(string columnName,object oValue)112 {113 Query q =new Query(table);114 q.QueryType = QueryType.Delete;115 q.AddWhere(columnName, oValue);116117return DataService.BuildCommand(q);118 }119120#endregion121122123 #region Persistence124125protected virtual void PreUpdate()126 {127 }128129protected virtual void PostUpdate()130 {131 }132133/// <summary>134 /// Saves this object's state to the selected Database.135 /// </summary>136public void Save()137 {138 Save(String.Empty);139 }140141/// <summary>142 /// Saves this object's state to the selected Database.143 /// </summary>144 /// <param name="userID"></param>145public void Save(int userID)146 {147 Save(userID.ToString());148 }149150/// <summary>151 /// Saves this object's state to the selected Database.152 /// </summary>153 /// <param name="userID"></param>154public void Save(Guid userID)155 {156string sUserID =string.Empty;157if (userID!=null)158 sUserID = userID.ToString();159160 Save(sUserID);161 }162163/// <summary>164 /// Saves this object's state to the selected Database.165 /// </summary>166 /// <param name="userName"></param>167public void Save(string userName)168 {169 PreUpdate();170171 QueryCommand cmd;172if (IsNew)173 {174 cmd = GetInsertCommand(userName);175 }176else177 {178 cmd = GetUpdateCommand(userName);179 }180181//reset the Primary Key with the id passed back by the operation182object pkVal = DataService.ExecuteScalar(cmd);183184//set the primaryKey, only if an auto-increment185 //if (table.PrimaryKey.AutoIncrement)186 // HACK: GUID fix187if (table.PrimaryKey.AutoIncrement || table.PrimaryKey.DataType == DbType.Guid)188 {189try {190 SetPrimaryKey(pkVal);191 }catch {192193//this will happen if there is no PK defined on a table. Catch this and notify194throw new Exception("No Primary Key is defined for this table. A primary key is required to use SubSonic");195 }196 }197198//set this object as old199 MarkOld();200 isDirty =false;201 PostUpdate();202203 }204205/// <summary>206 /// If the record contains Deleted or IsDeleted flag columns, sets them to true. If not, invokes Destroy()207 /// </summary>208 /// <returns>Number of rows affected by the operation</returns>209public static int Delete(object keyID)210 {211return DeleteByParameter(BaseSchema.PrimaryKey.ColumnName, keyID,null);212 }213214/// <summary>215 /// If the record contains Deleted or IsDeleted flag columns, sets them to true. If not, invokes Destroy()216 /// </summary>217 /// <param name="columnName">The name of the column that whose value will be evaluated for deletion</param>218 /// <param name="oValue">The value that will be compared against columnName to determine deletion</param>219 /// <returns>Number of rows affected by the operation</returns>220public static int Delete(string columnName,object oValue)221 {222return DeleteByParameter(columnName, oValue,null);223 }224225/// <summary>226 /// If the record contains Deleted or IsDeleted flag columns, sets them to true. If not, invokes Destroy()227 /// </summary>228 /// <param name="columnName">The name of the column that whose value will be evaluated for deletion</param>229 /// <param name="oValue">The value that will be compared against columnName to determine deletion</param>230 /// <param name="userName">The userName that the record will be updated with. Only relevant if the record contains Deleted or IsDeleted properties</param>231 /// <returns>Number of rows affected by the operation</returns>232public static int Delete(string columnName,object oValue,string userName)233 {234return DeleteByParameter(columnName, oValue, userName);235 }236237/// <summary>238 /// If the record contains Deleted or IsDeleted flag columns, sets them to true. If not, invokes Destroy()239 /// </summary>240 /// <param name="columnName">The name of the column that whose value will be evaluated for deletion</param>241 /// <param name="oValue">The value that will be compared against columnName to determine deletion</param>242 /// <param name="userName">The userName that the record will be updated with. Only relevant if the record contains Deleted or IsDeleted properties</param>243 /// <returns>Number of rows affected by the operation</returns>244private static int DeleteByParameter(string columnName,object oValue,string userName)245 {246int iOut = 0;247248bool containsDeleted = BaseSchema.Columns.Contains(ReservedColumnName.DELETED);249bool containsIsDeleted = BaseSchema.Columns.Contains(ReservedColumnName.IS_DELETED);250bool containsModifiedBy = BaseSchema.Columns.Contains(ReservedColumnName.MODIFIED_BY);251bool containsModifiedOn = BaseSchema.Columns.Contains(ReservedColumnName.MODIFIED_ON);252if (containsDeleted || containsIsDeleted)253 {254//update the column and set deleted=true;255 //new T();256 Query qry =new Query(BaseSchema);257if (containsDeleted)258 {259 qry.AddUpdateSetting(ReservedColumnName.DELETED,true);260 }261262if (containsIsDeleted)263 {264 qry.AddUpdateSetting(ReservedColumnName.IS_DELETED,true);265 }266267if (containsModifiedBy && !String.IsNullOrEmpty(userName))268 {269 qry.AddUpdateSetting(ReservedColumnName.MODIFIED_BY, userName);270 }271272if (containsModifiedOn)273 {274 qry.AddUpdateSetting(ReservedColumnName.MODIFIED_ON, DateTime.Now);275 }276 qry.AddWhere(columnName, oValue);277 qry.Execute();278 }279else280 {281 iOut = DestroyByParameter(columnName, oValue);282 }283return iOut;284 }285286/// <summary>287 /// Deletes the record in the table, even if it contains Deleted or IsDeleted flag columns288 /// </summary>289 /// <returns>Number of rows affected by the operation</returns>290public static int Destroy(object keyID)291 {292return DestroyByParameter(BaseSchema.PrimaryKey.ColumnName, keyID);293 }294295/// <summary>296 /// Deletes the record in the table, even if it contains Deleted or IsDeleted flag columns297 /// </summary>298 /// <param name="columnName">The name of the column that whose value will be evaluated for deletion</param>299 /// <param name="oValue">The value that will be compared against columnName to determine deletion</param>300 /// <returns>Number of rows affected by the operation</returns>301public static int Destroy(string columnName,object oValue)302 {303return DestroyByParameter(columnName, oValue);304 }305306/// <summary>307 /// Deletes the record in the table, even if it contains Deleted or IsDeleted flag columns308 /// </summary>309 /// <param name="columnName">The name of the column that whose value will be evaluated for deletion</param>310 /// <param name="oValue">The value that will be compared against columnName to determine deletion</param>311 /// <returns>Number of rows affected by the operation</returns>312private static int DestroyByParameter(string columnName,object oValue)313 {314 QueryCommand cmd = GetDeleteCommand(columnName, oValue);315return DataService.ExecuteQuery(cmd);316 }317318#endregion319320 #region Object Overrides321//public string Inspect() {322 // return Inspect(true);323 //}324 //public string Inspect(bool useHtml) {325 // System.Text.StringBuilder sb = new StringBuilder();326 // string sOut = "";327 // if (useHtml) {328 // sb.Append("<table><tr><td colspan=2><h3>" + this.TableName + " Inspection</h3></td></tr>");329330 // foreach (TableSchema.TableColumn col in table.Columns) {331 // sb.Append("<tr><td><b>" + col.ColumnName + "</b></td><td>" + this.GetColumnValue(col.ColumnName).ToString() + "</td></tr>");332333 // }334 // sb.Append("</table>");335 // sOut = sb.ToString();336 // } else {337 // sb.Append("#################" + this.TableName + " Inspection ####################\r\n");338339 // foreach (TableSchema.TableColumn col in table.Columns) {340 // sb.Append(col.ColumnName + ": " + this.GetColumnValue(col.ColumnName).ToString() + "\r\n");341342 // }343 // sb.Append("#############################################################################\r\n");344 // sOut = sb.ToString();345346 // }347 // return sOut;348 //}349#endregion350 }351}|||
Hello,
problem seems to me is OrderID, as trace said.
is Save function destroy all properties(including orderid) of the Object? (i don't see on above code, but suspicious)
try to this ??
first create a new guid:
dim orderID as guid = new system.guid.newguid()
for others create new guid from orderID, each may need to have new guid with same value
obj.OrderID = new guid(orderID.tobytearray)
Not sure, but try it. (debug: and see if OrderID value stays after Save function call)
|||Same thing. And here is my updated code:
Protected Sub btnCheckout_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnCheckout.ClickDim CartIDAs Integer = Session("CartID")Dim OrderIDAs Guid = System.Guid.NewGuid()Dim cOrderAs OnlineOrder =New OnlineOrder cOrder.OrderID =New Guid(OrderID.ToByteArray) cOrder.CartID = CartID cOrder.Status ="PEND" cOrder.PromoCode ="NONE" cOrder.Timestamp =Date.Now cOrder.CardTypeID = ddCardType.SelectedValue cOrder.CardNumber = Outman.Utility.QuickEncrypt(CardNumber.Text.Trim) cOrder.CardExp = ExpirationDate.Text cOrder.CardVerification = Outman.Utility.QuickEncrypt(CardVerification.Text) cOrder.Save()Dim sContactAs Contact =New Contact() sContact.OrderID =New Guid(OrderID.ToByteArray) sContact.Type ="SHIP" sContact.FirstName = sFirstName.Text.Trim sContact.LastName = sLastName.Text.Trim sContact.Company = sCompany.Text.Trim sContact.Address = sAddress.Text.Trim sContact.City = sCity.Text.Trim sContact.StateID = sState.SelectedValue sContact.ZipCode = sZipCode.Text.Trim sContact.Phone = sPhone.Text.Trim sContact.Email = sEmail.Text.Trim sContact.Save()Dim bContactAs Contact =New Contact() bContact.OrderID =New Guid(OrderID.ToByteArray) bContact.Type ="BILL" bContact.FirstName = bFirstName.Text.Trim bContact.LastName = bLastName.Text.Trim bContact.Company = bCompany.Text.Trim bContact.Address = bAddress.Text.Trim bContact.City = bCity.Text.Trim bContact.StateID = bState.SelectedValue bContact.ZipCode = bZipCode.Text.Trim bContact.Phone = bPhone.Text.Trim bContact.Email = bEmail.Text.Trim bContact.Save()Dim cCartAs Cart =New Cart(CartID) cCart.Status ="PEND" cCart.Save() Session.Add("CartID", Outman.ShoppingCart.Create) CartDisplay.Visible =False CheckoutComplete.Visible =True End Sub|||
Hello,
what/where is the function GetColumnValue, SetColumnValue ?
Public Property OrderIDAs Guid
152 Get
153 Dim resultAs Object =Me.GetColumnValue("OrderID")
154 Dim oOutAs Guid=Guid.Empty155 Try
156 oOut=New Guid(result.ToString())
157 Catch
158 End Try
159 Return oOut
160
161 End Get
162 Set
163 Me.MarkDirty()
164 Me.SetColumnValue("OrderID", Value)
165 End Set
166 End Property
Did you ever get this worked out?
I am having the same issue! I must have overlooked this post before I made mine a few minutes ago.
Did you try manually entering data through the table in SSMS? I found it had nothing to do with classes or page code. I cannot even enter it manually!
PLease advise if you found an answer.
Thanks!
No comments:
Post a Comment