you cannot save an array in the database, you need to save the values one by one

解决方案 »

  1.   

    but how can i do it?
      

  2.   

    你是要把数组sgring[] jobs所有项连起来放如意“向职业类型”字段吗?
    如果是 我想该先把各个项遍历出来+成string型的
    如果不是 
    那么 jobs.ToString()什么意思?
      

  3.   

    string[] jobs = ...
    string[] industries =....;foreach (string job in jobs)
     foreach (string industry in industries)
    {
       string sql= String.Format("insert into rc_info (意向职业类型,意向行业类型) values ('{0}','{1}')", job.Replace("'","''"), industry.Replace("'","''"));
      .....
    }
      

  4.   

    为什么会报错啊?C:\Inetpub\wwwroot\guan_isea\rc_newreg_resume_whatjob.aspx.cs(183): “System.Array”并不包含对“Replace”的定义就是这句
    jobs.Replace("'","''")
      

  5.   

    foreach (string job in jobs)
    ...
    job.Replace(...), not jobs.Replace, or simply do
    foreach (string job in jobs)
     foreach (string industry in industries)
    {
       string sql= String.Format("insert into rc_info (意向职业类型,意向行业类型) values ('{0}','{1}')", job, industry);
      .....
    }
      

  6.   

    foreach (string job in jobs)
    ...
    job.Replace(...), not jobs.Replace, or simply do
    foreach (string job in jobs)
     foreach (string industry in industries)
    {
       string sql= String.Format("insert into rc_info (意向职业类型,意向行业类型) values ('{0}','{1}')", job, industry);
      .....
    }这种方法存入数据库了,可是他是分成好多条记录存的就象这样:id      意向职业类型     意向行业类型   时间
    2         0030            0012  
    3         0040            0013
    4         0050            0014
    5         0060            0015
    6         0070            0016而我是想让他只存入一条记录,这样id   意向职业类型                    意向行业类型                 时间
    2    0030,0040,0050,0060            0012,0013,0014,0015,0016
      

  7.   

    string str;
    for(int i = 0;i<jobs.Lenth;i++)
    {
    str +=jobs[i]+"///";
    }
    把str 写如数据库
    读的时候读出来的时候用str.Spilet("///")
    就得到你要的数组!
      

  8.   

    string sql= String.Format("insert into rc_info (意向职业类型,意向行业类型) values ('{0}','{1}')", String.Join(",", jobs), String.Join(",",industries));
      

  9.   

    可以了!!我想把另外一个值也存入数据库中,不过他是一个string, 是一个单选的 select
    如下:string company_gm = company_scale.Value.ToString();  //取过来公司规模的值我这样写存不进去string sql= String.Format("insert into rc_info (意向职业类型,意向行业类型,公司规模) values ('{0}','{1}'),'{2}'", String.Join(",", jobs), String.Join(",",industries),String.Join(",",company_gm ));要改什么地方啊?
      

  10.   

    you misplaced ")"string sql= String.Format("insert into rc_info (意向职业类型,意向行业类型,公司规模) values ('{0}','{1}','{2}')", String.Join(",", jobs), String.Join(",",industries),company_gm);