The first contact does have a high threshold, thanks to the careful guidance of YOK big brother, DNC's group brings me so much .NET's good friend, I am so happy! Java Can! i can! -> NHIBERNATE This is a small example of the first database increasing, or it is ugly. Imports system.collectionsimports nhibitionnateimports nhibitionnate.cfgnamespace pb.testdal.db
Public class form1 inherits system.windows.Forms.form
#Region "Windows Form Designer Generated Code"
Public Sub new () mybase.new ()
'This call is required for the Windows Form Designer. InitializeComponent ()
'Add any initialization after INITIALIZECOMPONENT ()
End Sub
'Form rewriting Dispose to clean up the list of components. Protected overloads overrides sub dispose (byval disposing as boolean) ing disponation kiln (Components Is Nothing) Then components.dispose () end if endiffs) End sub
'Windows Form Designer Supply Private Components as System.comPonentModel.icontainer
'Note: The following procedure is necessary to use the Windows Form Designer to modify this process using the Windows Form Designer. 'Don't modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
DataGrid1 'Me.DataGrid1.DataMember = "" Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText Me.DataGrid1.Location = New System.Drawing.Point (152, 32) Me.DataGrid1.Name = "DataGrid1" Me .DataGrid1.Size = New System.Drawing.Size (288, 152) Me.DataGrid1.TabIndex = 3 '' Form1 'Me.AutoScaleBaseSize = New System.Drawing.Size (6, 14) Me.ClientSize = New System.Drawing .Size (456, 222) me.controls.add (me.datagrid1) me.controls.add (me.button3) me.controls.add (me.button2) me.controls.add (me.button1) me.name = "Form1" me.text = "form1" ctype (me.datagrid1, system.componentmodel.isupportinitialize) .endinit () me.resumeLayout (false) end SUB
#End region
Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cfg As New Configuration cfg.AddAssembly ( "WindowsApplication1") cfg.AddXmlFile ( "../ qqq.hbm.xml") DIM FACTORY As ISessionFactory = cfg.buildsessionFactory () DIM session as ity = factory.opensesis () DIM trx as itransaction = session.begintransaction ()
DIM VLIST As IList = Session.Find ("from windowsapplication1.pb.testdal.db.qqq")
DataGrid1.datasource = VLIST DATAGRID1.SETDATABINDING (VLIST, "")
TRX.commit () session.close ()
End Sub
Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'add data Dim cfg As New Configuration cfg.AddAssembly ( "WindowsApplication1") cfg.AddXmlFile ( "../ qqq.hbm. XML ") Dim Factory As ISessionFactory = cfg.buildsessionFactory () DIM session as ity = factory.opensession () DIM trx as itransaction = session.begintransaction () DIM Q AS New QQQ
Q.ID = "7" q.aaa = "a" q.bbb = "b"
Session.save (Q)
TRX.commit () session.close ()
End Sub
Private Sub Button2_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'update data Dim cfg As New Configuration cfg.AddAssembly ( "WindowsApplication1") cfg.AddXmlFile ( "../ qqq.hbm. XML ") DIM FACTORY As ISessionFactory = cfg.buildsessionFactory () DIM session as ity = factory.opensession () DIM trx as itransaction = session.begintransaction ()
DIM Q AS New QQQ
Q.ID = "1" q.aaa = "aa" q.bbb = "bb"
Session.Update (Q, "1")
TRX.commit () session.close ()
End Sub
Private Sub Button3_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'delete data Dim cfg As New Configuration cfg.AddAssembly ( "WindowsApplication1") cfg.AddXmlFile ( "../ qqq.hbm. XML ") Dim Factory As ISessionFactory = cfg.buildsessionFactory () DIM session as ity = factory.opensession () DIM trx as itransaction = session.begintransaction () DIM Q AS New QQQ
Q.ID = "2"
Session.delete (Q)
TRX.commit () session.close ()
End Sub End Classend Namespace