0
DataSet1 ds1 = new DataSet1();

ds1.tblSchedul.Rows.Add(0, "t_test", "4/10/2013 11:30:00 AM", "0", "D", "", "", "", "4/10/2013 8:15:45 AM", "2", "sub", "0");
tblSchedulBindingSource.DataSource = ds1.tblSchedul;

但它不起作用。有什么可能的解决方案??

4

2 回答 2

0

您需要为数据库表使用约会映射。首先,在DataTabel 中加载数据库表,并使用映射的方法来映射字段。

尝试查看此代码:Devexpress Mapping

于 2015-01-13T11:01:40.430 回答
0
   using System.Threading;
   using System.Text.RegularExpressions;
   using System.Data.Odbc;
   using DevExpress.XtraEditors.Controls;
   using DevExpress.XtraEditors;

   namespace Project
  {
  public partial class frmSchedule : Form
  {

      DataSet scheduleDataset;
      SQLConnection scheduleConn;
      SQLDataAdapter scheduleAdapter;
         private void Form1_Load(object sender, EventArgs e)
                {            
                        schedulerControl1.Start = DateTime.Now;
                        scheduleDataset = new DataSet();
                        scheduleConn = objconnection.getConnection();// DatabaseConnection
                        scheduleConn.Open();               
                        fillData("SELECT * FROM table_name"); 
                }

         private void fillData(string query)
            {
                scheduleDataset = new DataSet();
                scheduleAdapter = new SQLDataAdapter(query, scheduleConn);
                scheduleAdapter.RowUpdated += new SQLRowUpdatedEventHandler(scheduleAdapter_RowUpdated);
                scheduleAdapter.Fill(scheduleDataset, "table_name");

                this.appointmentsBS.DataSource = scheduleDataset;
                this.appointmentsBS.DataMember = "table_name";
                this.appointmentsBS.Position = 0;

                                    this.schedulerStorage1.Appointments.DataSource = this.appointmentsBS;
                                    this.schedulerStorage1.Appointments.Mappings.field1= "Field1";         
                                    this.schedulerStorage1.Appointments.Mappings.Field2= "Field2";



                               AppointmentCustomFieldMapping IDD = new AppointmentCustomFieldMapping("IDD", "IDD");
                               schedulerStorage1.Appointments.CustomFieldMappings.Add(IDD);


                SQLCommandBuilder cmdBuilder = new SQLCommandBuilder(scheduleAdapter);
                scheduleAdapter.InsertCommand = cmdBuilder.GetInsertCommand();
                scheduleAdapter.DeleteCommand = cmdBuilder.GetDeleteCommand();
                scheduleAdapter.UpdateCommand = cmdBuilder.GetUpdateCommand();
            }
}
}
于 2013-04-24T12:59:42.623 回答