void Form1_Load(object sender, EventArgs e)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) as num from dede_addonarticle");
DataTable dt = DbHelperMySQL.Query(strSql.ToString());
foreach (DataRow row in dt.Rows)
{
if (row["num"] != null)
{
num = Convert.ToInt32(row["num"]);
this.label1.Text = "当前数据:" + row["num"].ToString() + "条";
this.textBox2.Text = (num + 1).ToString();
}
}
}
private void button2_Click(object sender, EventArgs e)
{
//if (Convert.ToInt32(this.textBox2.Text.Trim()) <= num)
//{
// MessageBox.Show("主键ID太小,应从" + (num + 1) + "开始! ");
// return;
//}
int beginId = num + 1;
int max = Convert.ToInt32(this.textBox1.Text.Trim());
FileStream fs1 = new FileStream("C:\\Users\\JetLi\\Desktop\\sql.sql", FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1, Encoding.UTF8);
StringBuilder builder = new StringBuilder();
sw.WriteLine("USE db_tyweb;");
sw.WriteLine("INSERT INTO dede_archives VALUES ");//开始写入值
for (int i = beginId; i <= max; i++)
{
builder.Append("(" + i + ", 2, '0', 1394679024, 'c', 1, 1, 0, 122, 0, '" + i + "中国腾翼带您剖析微信支付与支付宝钱包的关键', '', '', 'admin', '未知', '', 1394679024, 1394679184, 1, '中国,腾翼,带您,剖析,微信支,付与,支付,宝,', 0, 0, 0, 0, 0, 0, '相似产品,内里逻辑有何不同?逻辑不一的后来者,为何对前者有持续压力? 本文主角:微信支付和支付宝钱包。 配角:微博支付、平安壹钱包、百度理财和网易理财。 本文结论:微', '', 1, 0, 0, " + (i - 1) + ")");
if (i != max)
{
builder.Append(",");
builder.Append("\t");
}
else
{
builder.Append(";");
}
}
sw.Write(builder.ToString());
builder = new StringBuilder();
sw.WriteLine("INSERT INTO dede_addonarticle VALUES ");//开始写入值
for (int i = beginId; i <= max; i++)
{
builder.Append("(" + i + ", 2, '中国腾翼带您剖析微信支付与支付宝钱包的关键', '', '', '127.0.0.1')");
if (i != max)
{
builder.Append(",");
builder.Append("\t");
}
else
{
builder.Append(";");
}
}
sw.Write(builder.ToString());
sw.Close();
fs1.Close();
}
c#生成大数据量sql文件_MySql
最新推荐文章于 2024-07-18 20:26:25 发布