本文整理汇总了C#中MySql.Data.MySqlClient.MySqlCommandBuilder.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlCommandBuilder.ToString方法的具体用法?C# MySqlCommandBuilder.ToString怎么用?C# MySqlCommandBuilder.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlCommandBuilder
的用法示例。
在下文中一共展示了MySqlCommandBuilder.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateNullTextFieldToEmptyString
public void UpdateNullTextFieldToEmptyString()
{
CreateDefaultTable();
execSQL("INSERT INTO Test (id, id2, name) VALUES (1, 1, NULL)");
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
cb.ToString(); // keep the compiler happy
DataTable dt = new DataTable();
da.Fill(dt);
dt.Rows[0]["name"] = "";
int updateCnt = da.Update(dt);
Assert.AreEqual(1, updateCnt);
dt.Rows.Clear();
da.Fill(dt);
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual("", dt.Rows[0]["name"]);
}
示例2: UpdateExtendedTextFields
public void UpdateExtendedTextFields()
{
execSQL("CREATE TABLE Test (id int, notes MEDIUMTEXT, PRIMARY KEY(id))");
execSQL("INSERT INTO Test VALUES(1, 'This is my note')");
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
cb.ToString(); // keep the compiler happy
DataTable dt = new DataTable();
da.Fill(dt);
dt.Rows[0]["notes"] = "This is my new note";
da.Update(dt);
dt.Clear();
da.Fill(dt);
Assert.AreEqual("This is my new note", dt.Rows[0]["notes"]);
}
示例3: Bug5798
public void Bug5798()
{
CreateDefaultTable();
execSQL("INSERT INTO Test (id, id2, name) VALUES (1, 1, '')");
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
cb.ToString(); // keep the compiler happy
DataTable dt = new DataTable();
da.Fill(dt);
Assert.AreEqual(String.Empty, dt.Rows[0]["name"]);
dt.Rows[0]["name"] = "Test";
da.Update(dt);
dt.Clear();
da.Fill(dt);
Assert.AreEqual("Test", dt.Rows[0]["name"]);
}
示例4: OriginalInName
public void OriginalInName()
{
CreateDefaultTable();
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM Test", conn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
cb.ToString(); // keep the compiler happy
DataTable dt = new DataTable();
da.Fill(dt);
DataRow row = dt.NewRow();
row["id"] = DBNull.Value;
row["id2"] = 1;
row["name"] = "Test";
row["dt"] = DBNull.Value;
row["tm"] = DBNull.Value;
row["ts"] = DBNull.Value;
row["OriginalId"] = 2;
dt.Rows.Add(row);
da.Update(dt);
Assert.AreEqual(1, dt.Rows.Count);
Assert.AreEqual(2, dt.Rows[0]["OriginalId"]);
}
示例5: UpdateDataSet
/// <summary>
/// Updates the given table with data from the given <see cref="DataSet"/>
/// </summary>
/// <param name="connectionString">Settings to use for the update</param>
/// <param name="commandText">Command text to use for the update</param>
/// <param name="ds"><see cref="DataSet"/> containing the new data to use in the update</param>
/// <param name="tablename">Tablename in the dataset to update</param>
public static void UpdateDataSet( string connectionString, string commandText, DataSet ds, string tablename )
{
MySqlConnection cn = new MySqlConnection( connectionString );
cn.Open();
MySqlDataAdapter da = new MySqlDataAdapter( commandText, cn );
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
cb.ToString();
da.Update( ds, tablename );
cn.Close();
}