欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net下降文本格式數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫中的代碼

 更新時間:2010年05月14日 16:54:37   作者:  
導(dǎo)入文本格式數(shù)據(jù)到數(shù)據(jù)庫中的代碼,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:

StreamReader sr = new StreamReader("E:\\123.txt");//文件路徑
string oneLine;
while ((oneLine = sr.ReadLine()) != null)
{
string[] str = oneLine.Split('|');
string sql = "insert into TableDX(number,name,produce,xinghao) values('" + str[0].ToString() + "','" + str[1].ToString().Replace("'","'") + "','" + str[2].ToString() + "','" + str[3].ToString() + "')";
string strConn = "Data Source=.;Initial Catalog=master;User ID=sa;Password=sa";//連接字符串
SqlConnection conn = new SqlConnection(strConn);

int res = 0;
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
res = cmd.ExecuteNonQuery();
conn.Close();
}
sr.Close();
this.Response.Write("<script>alert('導(dǎo)入成功');</script>");

相關(guān)文章

最新評論