本帖最后由 peter_zha 于 2010-01-19 12:47:40 编辑

解决方案 »

  1.   

    textbox.text 用数组来搞定他
     List<int> mylist = new List<int>();
    -----------------
     TextBox1.Text.Split(',');
    得到数组 用for循环写入数据库。
    如果不能搞定,我再给你详细代码
      

  2.   

    var rows=str.Split(@"\r\n");
    DataTable dt=new DataTable("dt");
    dt.Columns.Add("col0");
    dt.Columns.Add("col1");
    dt.Columns.Add("col2");
    dt.Columns.Add("col3");
    dt.Columns.Add("col4");
    foreach(var item in rows){
      DataRow dr=dt.NewRow();
      int i=0;
      foreach(var item2 in rows.Split(',')){
        dr[i]=item2;
      }
      dt.Rows.Add(dr);  
    }
      

  3.   

    读取出来,然后 "INSERT TB (A,B) SELECT "+你的字符串
      

  4.   

     完整的代码 
    string[] myarry = text1.Text.Split(',');
            int arrylen = myarry.Length;
            for (int i = 0; i < arrylen; i++)
            {
                reslut = myarry[i].ToString();
                string[] arryson = reslut.Split(' ');
                for (int j = 0; j < arryson.Length - 1; j++)
                {
                    string finall = arryson[j].ToString().Trim ();
                    string finPart = arryson[j + 1].ToString().Trim ();
                    string sqlstr = "select emid from dbo.T_Base_Employee where empart ='" + finPart + "' and emname= '" +  finall+ "'";
                    string recom = balcls.regCom(sqlstr );
                    string sqlinsert = "insert into T_Base_JoinInfo values('" + myid + "','" + recom.Trim () + "') ";
                    balcls.sqlcom(sqlinsert );
                }
            }
      

  5.   

    好,比楼上简单,我把文本调整了。
    er,234,rt,578,43@ 
    et,456,et,273,43@
    er,23,r,578,43@ 
    er,24,rt,78,43@
    er,234,rt,5,843@ 代码:string[] myarry = TextBox2.Text.Split('@');
           
            int arrylen = myarry.Length;
            for (int i = 0; i < arrylen-1; i++)
            {
                String positionid,prclasscode,amount;
                String tempstr3,tempstr4,tempstr5;
                int tempnum4,tempnum5,tempnum6;
                           String result = myarry[i].ToString();
                string[] arryson = result.Split(',');
                positionid = arryson[1].ToString();
                prclasscode= arryson[2].ToString();
                amount = arryson[3].ToString();
                .....
          }