1、将数据显示在界面上
代码
Session session = new Session();
session.ConnectionString = "Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa";
session.Connect();
//将数据显示在界面上
XPCollection xpc = new XPCollection(session,typeof(News));
this.gridControl1.DataSource = xpc;
session.ConnectionString = "Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa";
session.Connect();
//将数据显示在界面上
XPCollection xpc = new XPCollection(session,typeof(News));
this.gridControl1.DataSource = xpc;
将实体类数据提交到数据库中
代码
Session session = new Session();
session.ConnectionString = "Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa";
session.Connect();
News news = new News(session);//public class News : XPObject {}
news.Title = "标题";
news.Content = "内容";
news.Pub_Name = "发布人";
news.Pub_Date = Convert.ToDateTime("2010-5-7");
news.Save();//提交到数据库
session.ConnectionString = "Data Source=LIRAN;Initial Catalog=Liran_data;User ID=sa;Password=sa";
session.Connect();
News news = new News(session);//public class News : XPObject {}
news.Title = "标题";
news.Content = "内容";
news.Pub_Name = "发布人";
news.Pub_Date = Convert.ToDateTime("2010-5-7");
news.Save();//提交到数据库