本文整理汇总了C#中System.Data.DataSet.AcceptChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.AcceptChanges方法的具体用法?C# DataSet.AcceptChanges怎么用?C# DataSet.AcceptChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataSet
的用法示例。
在下文中一共展示了DataSet.AcceptChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSerializeDataSet
public void TestSerializeDataSet()
{
DataSet ds = new DataSet("DataSet");
//Table 1
ds.Tables.Add(new DataTable("Table"));
ds.Tables[0].Columns.Add("col1", typeof(int));
ds.Tables[0].Columns.Add("col2", typeof(int));
DataRow dr = ds.Tables[0].NewRow();
dr["col1"] = 1;
dr["col2"] = 2;
ds.Tables[0].Rows.Add(dr);
//Table 2
ds.Tables.Add(new DataTable("Table1"));
ds.Tables[1].Columns.Add("col1_col1", typeof(int));
ds.Tables[1].Columns.Add("col2", typeof(int));
dr = ds.Tables[1].NewRow();
dr["col1_col1"] = 1;
ds.Tables[1].Rows.Add(dr);
ds.Relations.Add(new DataRelation("table_table1", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0], true));
ds.AcceptChanges();
string actualXml = XmlSerializationHelper.SerializeDataTable(ds.Tables[0], true);
string expectedXml = "<DataSet><Table><col1>1</col1><col2>2</col2></Table><Table1><col1_col1>1</col1_col1></Table1></DataSet>";
Trace.Write(actualXml);
Assert.AreEqual(actualXml, expectedXml);
}
示例2: GetDataSet
/// <summary>
/// Retrieve excel data and convert it to dataset
/// </summary>
/// <param name="file">Excel binary file.</param>
/// <returns>Dataset containing the data of the sheet pertaining to the position specified</returns>
public DataSet GetDataSet(byte[] file)
{
try
{
//try to create an excel application
CreateExcelApplication();
KeepFiles = false;
OpenWorkbook(file);
List<string> sheets = new List<string>();
foreach (Worksheet s in Application.Worksheets)
{
//ignore hidden sheets
if (s.Visible != XlSheetVisibility.xlSheetVisible)
{
continue;
}
sheets.Add(s.Name);
//release com obj
ReleaseComObject(s);
}
//read respective sheets
DataSet ds = new DataSet();
foreach (string s in sheets)
{
ds.Tables.Add(GetExcelData(s));
}
ds.AcceptChanges();
return ds;
}
finally
{
this.Dispose();
}
}
示例3: Main
static void Main(string[] args)
{
// string connectionString = @"data source=(localDB)\v11.0; Initial catalog=TrainingDB; integrated security=SSPI";
//string connectionString = "data source=192.168.20.125;database=SMSDB;Integrated Security=false; user id=sa; [email protected]";
string connectionString = @"Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\TrainingDB.mdf;Initial Catalog=TrainingDB;Integrated Security=True";
string commandString = @"SELECT * FROM Shippers";
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, connectionString);
SqlCommandBuilder scb = new SqlCommandBuilder(dataAdapter);
DataSet myDataSet = new DataSet();
dataAdapter.Fill(myDataSet, "Shippers");
DataTable sTable = myDataSet.Tables["Shippers"];
// add data
object[] o = { 1, "General", "555-1212" };
sTable.Rows.Add(o);
dataAdapter.Update(myDataSet, "Shippers");
myDataSet.AcceptChanges();
Console.ReadKey();
}
示例4: getmenu
public DataSet getmenu(string department)
{
EmployeeDao employeedao = new EmployeeDao();
Employee employee = employeedao.getempdepartment(department);
ConnectionDao ConnectionDao = new ConnectionDao();
SqlDataAdapter adp = new SqlDataAdapter("select department_name,weburl from Department where Department_Name='" + employee.department + "'", ConnectionDao.getConnection());
DataSet ds4 = new DataSet();
adp.Fill(ds4);
string Department = ds4.Tables[0].Rows[0]["department_name"].ToString();
if (Department == "Sales")
{
ds4 = addMenu(ds4, "Email");
}
if (Department == "Corporate")
{
ds4.Tables[0].Rows.RemoveAt (0);
ds4.AcceptChanges();
ds4 = addMenu(ds4, "Customer");
ds4 = addMenu(ds4, "Email");
ds4 = addMenu(ds4, "Ticketing");
ds4 = addMenu(ds4, "Dashboard");
ds4 = addMenu(ds4, "Reports");
}
return ds4;
}
示例5: TestMethod1
public void TestMethod1()
{
DataSet dataSet = new DataSet("dataSet");
dataSet.Namespace = "NetFrameWork";
DataTable table = new DataTable();
DataColumn idColumn = new DataColumn("id", typeof(int));
idColumn.AutoIncrement = true;
DataColumn itemColumn = new DataColumn("item");
table.Columns.Add(idColumn);
table.Columns.Add(itemColumn);
dataSet.Tables.Add(table);
for (int i = 0; i < 2; i++)
{
DataRow newRow = table.NewRow();
newRow["item"] = "item " + i;
table.Rows.Add(newRow);
}
dataSet.AcceptChanges();
var jsonResult = OrbCore.toJson(dataSet);
Console.WriteLine(jsonResult);
}
示例6: GetReleaseFileInfo
public DataSet GetReleaseFileInfo(string componentCode, string version)
{
// get XML doc
XDocument xml = GetReleasesFeed();
// get current release
var release = (from r in xml.Descendants("release")
where r.Parent.Parent.Attribute("code").Value == componentCode
&& r.Attribute("version").Value == version
select r).FirstOrDefault();
if (release == null)
return null; // requested release was not found
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add();
dt.Columns.Add("ReleaseFileID", typeof(int));
dt.Columns.Add("FullFilePath", typeof(string));
dt.Columns.Add("UpgradeFilePath", typeof(string));
dt.Columns.Add("InstallerPath", typeof(string));
dt.Columns.Add("InstallerType", typeof(string));
dt.Rows.Add(
Int32.Parse(release.Element("releaseFileID").Value),
release.Element("fullFilePath").Value,
release.Element("upgradeFilePath").Value,
release.Element("installerPath").Value,
release.Element("installerType").Value);
ds.AcceptChanges(); // save
return ds;
}
示例7: wfrm_System_Frame
/// <summary>
///
/// </summary>
/// <param name="serverAPI"></param>
public wfrm_System_Frame(ServerAPI serverAPI)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
try
{
m_ServerAPI = serverAPI;
dsSettings = m_ServerAPI.GetSettings();
dsSettings.AcceptChanges();
}
catch(Exception x){
wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
frm.ShowDialog(this);
}
InitTab();
}
示例8: Load_ListDS
public static void Load_ListDS()
{
if (File.Exists(m_MySensors_FilePath))
{
SensorDS = new DataSet("SensorDS");
SensorDS.ReadXml(m_MySensors_FilePath, XmlReadMode.ReadSchema);
}
else
{
if (SensorDS != null)
{
SensorDS.Dispose();
GC.Collect();
}
DataTable dt0 = new DataTable("SensorTBL");
dt0.Columns.Add(new DataColumn(Cfg.C_IS_PICK, Type.GetType(Cfg.SYS_INT32)));
dt0.Columns[Cfg.C_IS_PICK].DefaultValue = 1;
dt0.Columns.Add(new DataColumn(Sensor.C_SENSOR_ID, Type.GetType(Cfg.SYS_INT64)));
dt0.Columns[Sensor.C_SENSOR_ID].DefaultValue = Sensor.Sensor_ID;
dt0.Columns.Add(new DataColumn(Sensor.C_LOCATION_NAME, Type.GetType(Cfg.SYS_STRING)));
dt0.Columns[Sensor.C_LOCATION_NAME].DefaultValue = Sensor.Location_Name;
dt0.Rows.Add(dt0.NewRow());
dt0.AcceptChanges();
SensorDS = new DataSet("SensorDS");
SensorDS.Tables.Add(dt0);
SensorDS.AcceptChanges();
}
SensorDS.Tables[0].DefaultView.Sort = Sensor.C_SENSOR_ID;
}
示例9: Abrir_Login
public static NavisionDBUser Abrir_Login(string UserId, string Password, ref DataSet DsRes, NavisionDBConnection DBConn)
{
NavisionDBUser DBUser = null;
DsRes = Utilidades.GenerarResultado("No conectado");
DsRes.Tables[0].Columns.Add("Connected", Type.GetType("System.Boolean"), "false");
DsRes.Tables[0].AcceptChanges();
try
{
DBUser = DBConn.DoLogin(UserId, Password, ref DsRes);
//Obtengo los roles
if ((DsRes.Tables.Count > 0) && (DsRes.Tables[0].Columns.Count > 0) && (!DsRes.Tables[0].Columns.Contains("Error")))
if (Convert.ToBoolean(DsRes.Tables[0].Rows[0]["Connected"]) == true)
{
DsRes.Tables[0].Columns.Add("Administracion", System.Type.GetType("System.Boolean"));
DsRes.Tables[0].Columns.Add("Gestion", System.Type.GetType("System.Boolean"));
DsRes.Tables[0].Columns.Add("Compras", System.Type.GetType("System.Boolean"));
DsRes.Tables[0].Columns.Add("Mensajería", System.Type.GetType("System.Boolean"));
DsRes.Tables[0].Columns.Add("Comercial", System.Type.GetType("System.Boolean"));
NavisionDBTable dt = new NavisionDBTable(DBConn, DBUser);
NavisionDBCommand cmd = new NavisionDBCommand(DBConn);
NavisionDBDataReader rd;
dt.TableName = "Mobile Users";
dt.AddColumn("Administracion");
dt.AddColumn("Gestion");
dt.AddColumn("Compras");
dt.AddColumn("Mensajería");
dt.AddColumn("Comercial");
dt.AddFilter("User ID", UserId);
dt.AddFilter("Password", Password);
cmd.Table = dt;
rd = cmd.ExecuteReader(false);
if (rd.RecordsAffected > 0)
{
DsRes.Tables[0].Rows[0]["Administracion"] = rd.GetBoolean(0);
DsRes.Tables[0].Rows[0]["Gestion"] = rd.GetBoolean(1);
DsRes.Tables[0].Rows[0]["Compras"] = rd.GetBoolean(2);
DsRes.Tables[0].Rows[0]["Mensajería"] = rd.GetBoolean(3);
DsRes.Tables[0].Rows[0]["Comercial"] = rd.GetBoolean(4);
}
DsRes.Tables[0].AcceptChanges();
DsRes.AcceptChanges();
}
return DBUser;
}
catch (Exception ex)
{
Utilidades.GenerarError(UserId, "Abrir_Login()", ex.Message);
return null;
}
}
示例10: MainForm_Load
void MainForm_Load (object sender, EventArgs e)
{
_dataSet = new DataSet ();
_dataSet.ReadXml ("test.xml");
_dataGrid.DataSource = _dataSet;
_dataGrid.DataMember = "Table";
_dataSet.AcceptChanges ();
}
示例11: getDataSet
private static DataSet getDataSet()
{
DataSet op_ds=new DataSet();
DataTable v_dt=new DataTable();
op_ds.Tables.Add(v_dt);
op_ds.AcceptChanges();
return op_ds;
}
示例12: btnAddRcd_Click
protected void btnAddRcd_Click(object sender, EventArgs e)
{
this.txtSN.Focus();
if (this.txtSN.Text.Trim() == "")
{
Methods.AjaxMessageBox(this, "物料序列号不能为空!"); return;
}
int rc = Methods.getMatierialIDCount(this.txtSN.Text.Trim());
if (rc > 0)
{
Methods.AjaxMessageBox(this, "此物料序列号已经存在!"); return;
}
else if (rc < 0) { Methods.AjaxMessageBox(this, "查询部件序列号时出现异常,详情请查看日志!"); return; }
ds = (DataSet)ViewState["tmpds"];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (this.txtSN.Text.Trim() == ds.Tables[0].Rows[i]["ID"].ToString())
{
Methods.AjaxMessageBox(this, "此物料序列号已经存在!"); return;
}
}
int Len = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MIDLenInSN"]);
if (this.txtSN.Text.Trim().Length <= Len)
{
Methods.AjaxMessageBox(this, "此部件序列号长度必须" + Len + "位以上!"); return;
}
DataRow r = ds.Tables[0].NewRow();//将数据源添加一新行
string mid = this.txtSN.Text.Trim().Substring(0, Len);
//if(mid!=ModelID)
//{
// Methods.AjaxMessageBox(this,"序列号对应的品号与计划中的品号不一致!"); return;
//}
//WSProcedureCtrl.ProcedureCtrl pctrl = new ProcedureCtrl();
//if (!pctrl.CheckModel(mid, SessionUser.ID))
//{
// Methods.AjaxMessageBox(this, "序列号对应的品号与计划中的品号不一致!"); return;
//}
r["ID"] = this.txtSN.Text.Trim();
r["ModelID"] = mid;
r["Batch"] = "";
r["Vendor"] = "";
r["EmployeeID"] = "";
r["FoundTime"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd");
r["Remark"] = "";
ds.Tables[0].Rows.InsertAt(r, 0);
ds.AcceptChanges();
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
}
示例13: MyTestInitialize
public void MyTestInitialize()
{
dataSet = new DataSet("TestSet");
dataSet.Tables.Add("Property");
dataSet.Tables["Property"].Columns.Add("Property", typeof (string));
dataSet.Tables["Property"].Columns.Add("Value", typeof(string));
dataSet.Tables["Property"].Rows.Add(new object[] {"MyName", "Put Stuff Here" });
dataSet.AcceptChanges();
}
示例14: btnsave_Click
/// <summary>
/// it saves the data edited in the same file and gives a message box that its done.. and also can be done for multiple nodes
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void btnsave_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("BasicInfo.xml"); //taking new file and saving in it....
ds.Tables[0].Rows[0]["name"] = "hi";// rtxtshow.Text; //taking node and saving it
ds.AcceptChanges();
ds.WriteXml("BasicInfo.xml");
MessageBox.Show("FILE UPDATED....");
}
示例15: WriteDefaultLanguage
//修改默认语言
public static void WriteDefaultLanguage(string lang)
{
DataSet ds = new DataSet();
ds.ReadXml("LanguageDefine.xml");
DataTable dt = ds.Tables["Language"];
dt.Rows[0]["DefaultLanguage"] = lang;
ds.AcceptChanges();
ds.WriteXml("LanguageDefine.xml");
}