代码之家  ›  专栏  ›  技术社区  ›  Brad Robinson

MySQL提供程序的子音速崩溃

  •  0
  • Brad Robinson  · 技术社区  · 15 年前

    我正在使用亚音速3.0.0.3和ActiveRecord,运行在一个MySQL数据库上。我发现这很管用:

    // Approach 1
    var db = new testDB(); 
    db.Insert.Into<company>(c => c.name) .Values("Acme") .Execute(); 
    

    但这次崩溃:

    // Approach 2
    company c = new company(); 
    c.name = "Acme"; 
    c.Save(); 
    

    崩溃不是立即发生的,而是在关机时发生的:

    One of the background threads threw exception: System.NullReferenceException: Object reference not set to an instance of an object.
       at MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)
       at MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns)
       at MySql.Data.MySqlClient.Driver.SkipDataRow()
       at MySql.Data.MySqlClient.ResultSet.Close()
       at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
       at MySql.Data.MySqlClient.MySqlDataReader.Close()
       at MySql.Data.MySqlClient.MySqlConnection.Close()
       at MySql.Data.MySqlClient.MySqlConnection.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Finalize()
    Test host process exited unexpectedly.
    

    考虑到使用方法1,我不知道如何获取新插入的记录ID,而使用方法2,它会崩溃,我有点卡住了……

    有什么想法吗?

    1 回复  |  直到 15 年前
        1
  •  2
  •   Brad Robinson    15 年前

    http://github.com/subsonic/SubSonic-3.0 似乎可以解决这个问题。(我以前使用的是下载自 http://subsonicproject.com/Download )

    推荐文章