public void Add(IDataProvider provider){
var key=KeyValue();
if(key==null){
var newKey=_repo.Add(this,provider);
this.SetKeyValue(newKey);
}else{
_repo.Add(this,provider); //NullReferenceException was unhandled by user code
}
SetIsNew(false);
OnSaved();
}
'這' 包含亞音速3.0.0.4的ActiveRecord模板MySQL錯誤上插入新記錄
this
{Geocine}
_age: null
_birthday: null
_church_id: null
_db: {Seminary.Data.SeminaryDB}
_dirtyColumns: Count = 0
_finalgrade: null
_finalgrade_equivalent: null
_first_name: "Geocine"
_gender: null
_isLoaded: false
_isNew: true
_last_name: "Cruz"
_level: null
_middle_name: "Reilly"
_repo: {SubSonic.Repository.SubSonicRepository<Seminary.Data.student>}
_semester_enrolled: null
_seminary_id: null
_student_id: 0
_year_enrolled: null
age: null
birthday: null
church_id: null
Columns: Count = 14
finalgrade: null
finalgrade_equivalent: null
first_name: "Geocine"
gender: null
last_name: "Cruz"
level: null
middle_name: "Reilly"
semester_enrolled: null
seminary_id: null
student_id: 0
tbl: {student}
TestMode: false
year_enrolled: null
提供商包含
provider
{SubSonic.DataProviders.DbDataProvider}
[SubSonic.DataProviders.DbDataProvider]: {SubSonic.DataProviders.DbDataProvider}
Client: MySqlClient
ConnectionString: "Data Source=localhost;Database=school;User Id=root;Password=123456;Port=3306;"
CurrentSharedConnection: null
DbDataProviderName: "MySql.Data.MySqlClient"
Factory: {MySql.Data.MySqlClient.MySqlClientFactory}
Log: null
Name: "MySql.Data.MySqlClient"
ParameterPrefix: "@"
Schema: {SubSonic.Schema.DatabaseSchema}
SchemaGenerator: {SubSonic.SqlGeneration.Schema.MySqlSchema}
這裏是堆棧跟蹤
[NullReferenceException: Object reference not set to an instance of an object.]
MySql.Data.MySqlClient.MySqlConnection.get_ServerThread() +6
MySql.Data.MySqlClient.MySqlConnection.Abort() +54
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +839
MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +4
System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10
SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) +175
SubSonic.Repository.SubSonicRepository`1.Add(T item, IDataProvider provider) +165
Seminary.Data.student.Add(IDataProvider provider) in C:\Users\SomeUser\Documents\Visual Studio 2008\Projects\Seminary\ActiveRecord\ActiveRecord.cs:2490
Seminary.Data.student.Save(IDataProvider provider) in C:\Users\SomeUser\Documents\Visual Studio 2008\Projects\Seminary\ActiveRecord\ActiveRecord.cs:2505
Seminary.Data.student.Save() in C:\Users\SomeUser\Documents\Visual Studio 2008\Projects\Seminary\ActiveRecord\ActiveRecord.cs:2499
Seminary.Default.btnAdd_Click(Object sender, EventArgs e) in C:\Users\SomeUser\Documents\Visual Studio 2008\Projects\Seminary\Default.aspx.cs:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
這裏是一個叫錯誤代碼:
student studentObject = new student();
studentObject.first_name = txtFirstName.Text;
studentObject.middle_name = txtMiddleName.Text;
studentObject.last_name = txtLastName.Text;
studentObject.Save();
嗨,謝謝你給我的希望。 http://unxutils.sourceforge.net/UnxUtils.zip - >這似乎是一個死鏈接:(在這裏找到它,http://sourceforge.net/projects/unxutils/files/unxutils/current/UnxUtils。 zip/download會嘗試安裝它 – 2010-11-10 15:38:39
那麼,作爲一種替代方法,您可以在您最喜歡的文本瀏覽器中打開query.log,但由於文件在我的開發機器上快速增長到1GB以上(因爲每一個查詢都被記錄),我更喜歡'tail -f'方法,因爲我立即看到新的查詢。Btw。我不會建議在生產服務器上激活它;) – 2010-11-10 16:10:53
我正在使用mysql gui工具來查看一般查詢日誌,我有一列是空的那需要有價值。 :) – 2010-11-10 16:15:38