SqlConnection con = new SqlConnection("server=xss;initial catalog=lxy;user Id=sa;password=1"); string strSQL="SELECT * FROM result"; SqlDataAdapter da=new SqlDataAdapter(strSQL,con);
SqlCommandBuilder MyCB = new SqlCommandBuilder(da); DataSet ds1 = new DataSet(); da.Fill(ds1,"result");
StreamReader objStreamReader=new StreamReader("c:\\apriori\\data.rules"); string Line=""; char[] cha={' '}; int j;
string strSQL="SELECT * FROM result";
SqlDataAdapter da=new SqlDataAdapter(strSQL,con);
SqlCommandBuilder MyCB = new SqlCommandBuilder(da);
DataSet ds1 = new DataSet();
da.Fill(ds1,"result");
StreamReader objStreamReader=new StreamReader("c:\\apriori\\data.rules");
string Line="";
char[] cha={' '};
int j;
while(objStreamReader.Peek()!=-1)
{
Line=objStreamReader.ReadLine();//读取一行数据
string[] Values=Line.ToString().Split(cha); //根据空格分成数组
DataRow r=ds1.Tables[0].NewRow();
for(j=0;j<Values.Length;j++)
{
Response.Write(Values[j]);
}
for(j=0;j<Values.Length;j++)
{ //ds.Tables[tablename].Rows[i][j]=Values[j];//将数组值赋给字段
r[j+1]=Values[j]; }
ds1.Tables[0].Rows.Add(r);
}
da.Update(ds1);
}
是就改为:
DataRow r=ds1.Tables["result"].NewRow();