CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

小女子的这个问题还不小哦~

楼主yangyanli(乌托邦主·蛤蟆)2003-05-03 09:39:23 在 Web 开发 / ASP 提问

表temp:三个字段,xingming,kecheng,fenshu,成绩表了  
  表temp1:只有一个字段,xingming,他的记录是没有重复的姓名列表。从temp查出来的  
  表temp2:只有一个字段,kecheng,他的记录是没有重复的课程列表。从temp查出来的  
  表temp3:够造的一个新表:::  
   
  str="姓名   varchar(12),"  
  sql="select   *   from   temp2"  
  set   rs=newconn.execute(sql)  
  do   while   not   rs.eof  
  str=str&rs("kecheng")&"   varchar(20),"  
  rs.movenext  
  loop  
  rs.close  
  set   rs=nothing  
  strSql=left(str,len(str)-1)  
  createSql="Create   table   temp3"&"("   &   strSql&")"  
  newconn.execute(createSql)  
  这样表temp3的字段如下:  
  姓名,计算机,数学,外语,……  
   
  我现在的问题:  
  怎么样通过一个循环,来填写temp3表:在temp成绩表中有对应的成绩,则写如响应的位置成绩;如果没有,则写入“X"。  
   
  简单的例子:  
  temp::  
  张一         计算机         70  
  张一         数学             80  
  李一         数学             90  
  李一         外语             100  
   
  temp1:::张一       李一  
  temp2:::计算机,数学,外语  
   
  temp3:  
  姓名       计算机         数学       外语(字段)         总分       平均分    
   
  我希望的表temp3中的数据:  
  张一         70               80             X                   ??                   ??  
  李一         X                 90             100               ??                   ??  
   
  请教如何实现。  
   
   
  如果大哥哥你看懂了偶的意思,并且您也知道怎么来做,教教小mm我好吗?  
  问题点数:10、回复次数:28Top

1 楼Jason_guo(梦想难成,努力能成!)回复于 2003-05-03 09:49:44 得分 0

看得头晕了。Top

2 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 10:05:43 得分 0

修该了一点:  
  strSql=left(str,len(str)-1)  
  strSql=strSql&",总分   varchar(6),平均分   varchar(4)"  
  createSql="Create   table   temp3"&"("   &   strSql&")"  
  Top

3 楼anqiant(许留心)回复于 2003-05-03 10:43:30 得分 0

'首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof  
  while   not   rs.eof  
  '打开temp3进行添加  
  set   rs01=server.createObject("adodb.recordset")  
  sql="Select   *   From   temp3"  
  rs01.open   sql,conn,1,3  
   
  a=rs01.fielscount-1  
  for   i=1   to   a  
  '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
  sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
  set   rs02=newconn.execute(sql)  
  '循环执行查询将成绩付给数组  
  if   rs02.eof   and   rs02.bof  
  a(i)="x"  
  else  
  a(i)=rs02("fenshu")  
  end   if  
   
  next  
  rs02.close  
  set   rs02=nothing  
  '循环添加记录  
  rs01.addnew  
  rs01("姓名")=rs("xingming")  
  i=1  
  while   i>a  
  rs01(rs01(i).name)=a(i)  
  i=i+1  
  wend  
  rs01.update  
  rs01.close  
  set   rs01=nothing  
   
  rs.movenext  
  wend  
  end   if  
  rs.close  
  set   rs=nothing  
   
   
  早上刚起来,头有点晕,写的不对我们在讨论。  
  过几天还要去参加《电路分析》的冲刺考试,能不能毕业就看这次了,唉!  
  Top

4 楼anqiant(许留心)回复于 2003-05-03 10:50:38 得分 0

你又改了,那你把这一句  
  '对列进行记数  
  a=rs01.fielscount-1  
  改成  
  a=rs01.fielscount-3  
  好了  
   
  这里  
  while   i>a  
  rs01(rs01(i).name)=a(i)  
  i=i+1  
  wend  
  再改  
  while   i>a  
  rs01(rs01(i).name)=a(i)  
  b=b+a(i)  
  i=i+1  
  wend  
  c=b/a  
  rs01("总分")=b  
  rs01("平均分")=c  
   
   
  你的《电路分析》学得怎样,我怎么看着就头晕,聊聊好吧,我的设计也是ASP的。  
  Top

5 楼ekun008(阿昆)回复于 2003-05-03 10:51:10 得分 0

问题是不小,但是分数呢就小了点啦。  
  有了上面的回答应该解决问题了吧/Top

6 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 11:01:20 得分 0

<%  
  '首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof   then  
  while   not   rs.eof//////////////////////////////////////do???  
  '打开temp3进行添加  
  set   rs01=server.createObject("adodb.recordset")  
  sql="Select   *   From   temp3"  
  rs01.open   sql,newconn,1,3  
  a=rs01.fielscount-1    
  ///////////////////////////////////Microsoft   VBScript   运行时错误   (0x800A01B6  
  for   i=1   to   a  
  '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
  sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
  set   rs02=newconn.execute(sql)  
  '循环执行查询将成绩付给数组  
  if   rs02.eof   and   rs02.bof   then  
  a(i)="x"  
  else  
  a(i)=rs02("fenshu")  
  end   if  
   
  next  
  rs02.close  
  set   rs02=nothing  
  '循环添加记录  
  rs01.addnew  
  rs01("姓名")=rs("xingming")  
  i=1  
  while   i>a  
  rs01(rs01(i).name)=a(i)  
  i=i+1  
  wend///////////////////////////////////////不懂  
  rs01.update  
  rs01.close  
  set   rs01=nothing  
   
  rs.movenext  
  wend/////////////////////////while         wend??  
  end   if  
  rs.close  
  set   rs=nothing  
   
   
   
  %>  
  Top

7 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 11:05:26 得分 0

a=rs01.fielscount-3  
   
  Microsoft   VBScript   运行时错误   (0x800A01B6)Top

8 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 11:07:17 得分 0

分数是小事,助人乃快乐之本,嫌少是吧,要不要把我的200分都给你?Top

9 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 11:19:37 得分 0

修改了一些:::  
   
  '打开temp3进行添加  
  set   rs01=server.createObject("adodb.recordset")  
  sql="Select   *   From   temp3"  
  rs01.open   sql,newconn,1,3  
  for   i=1   to   rs01.Fields.Count-3  
  '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
  sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
  set   rs02=newconn.execute(sql)  
  '循环执行查询将成绩付给数组  
  if   rs02.eof   and   rs02.bof   then  
  a(i)="x"  
  else  
  a(i)=rs02("fenshu")////////////////////  
   
  这里::::Microsoft   VBScript   运行时错误   (0x800A000D)  
  end   if  
   
  next  
  Top

10 楼anqiant(许留心)回复于 2003-05-03 14:44:54 得分 0

<%  
  '首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof  
          while   not   rs.eof                       '如果游标没到底,也就是记录没到最后一条的话,就执行  
                  '打开temp3进行添加  
                  set   rs01=server.createObject("adodb.recordset")  
                  sql="Select   *   From   temp3"  
                  rs01.open   sql,conn,1,3  
   
                  a=rs01.fieldscount-3  
                  for   i=1   to   a  
                          '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
                          sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
                          set   rs02=newconn.execute(sql)  
                          '循环执行查询将成绩付给数组  
                          if   rs02.eof   and   rs02.bof  
                                  a(i)="x"  
                          else  
                                  a(i)=rs02("fenshu")  
                          end   if  
   
                  next  
                  rs02.close  
                  set   rs02=nothing  
                  '循环添加记录  
                  rs01.addnew  
                  rs01("姓名")=rs("xingming")  
                  i=1  
                  while   not   i>a  
                          rs01(rs01(i).name)=a(i)  
                          b=b+a(i)  
                          i=i+1  
                  wend  
                  c=b/a  
                  rs01("总分")=b  
                  rs01("平均分")=c  
   
                  rs01.update  
                  rs01.close  
                  set   rs01=nothing  
   
                  rs.movenext  
          wend  
  end   if  
  rs.close  
  set   rs=nothing  
   
  %>Top

11 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 14:48:57 得分 0

<%  
  '首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof   then  
  while   not   rs.eof  
  '打开temp3进行添加  
  set   rs01=server.createObject("adodb.recordset")  
  sql="Select   *   From   temp3"  
  rs01.open   sql,newconn,1,3  
  for   i=1   to   rs01.Fields.Count-3  
  '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
  sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
  set   rs02=newconn.execute(sql)  
  '循环执行查询将成绩付给数组  
  if   rs02.eof   and   rs02.bof   then  
  a(i)="x"  
  else  
  a(i)=rs02("fenshu")'这里有错!见上面  
   
   
   
  错误发生。  
   
  end   if  
   
  next  
  rs02.close  
  set   rs02=nothing  
  '循环添加记录  
  rs01.addnew  
  rs01("姓名")=rs("xingming")  
  i=1  
  while   i>a  
  rs01(rs01(i).name)=a(i)  
  b=b+a(i)  
  i=i+1  
  wend  
  c=b/a  
  rs01("总分")=b  
  rs01("平均分")=c  
   
  rs01.update  
  rs01.close  
  set   rs01=nothing  
   
  rs.movenext  
  wend  
  end   if  
  rs.close  
  set   rs=nothing  
   
   
   
  %>  
  Top

12 楼anqiant(许留心)回复于 2003-05-03 14:49:38 得分 0

'你先定义一个数组,上午我把rs01.Fields.Count写错了,不好意思。  
  dim   a(rs01.Fields.Count-3)  
  '循环执行查询将成绩付给数组  
  if   rs02.eof   and   rs02.bof  
          a(i)="x"  
  else  
          a(i)=rs02("fenshu")  
  end   if  
   
  Top

13 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 14:54:09 得分 0

Microsoft   VBScript   编译器错误   (0x800A0402)  
  /asp/xsgl/quest10.asp,   第   52   行,   第   6   列  
  dim   a(rs01.Fields.Count-3)  
  -----^  
   
  数组怎么定义??Top

14 楼anqiant(许留心)回复于 2003-05-03 14:55:56 得分 0

我知道,我重定义了数组,这是不对的,让我再想想。Top

15 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:12:29 得分 0

那你什么时候能想好呢。。。。。。。。。。。。。。。。。。  
   
  我也不知道怎么定义数组。  
   
  原来我想用叔祖的时候,都因为不会定义而放弃了。。。。Top

16 楼loveyou1234(fuck)回复于 2003-05-03 15:17:40 得分 0

就因为是女孩就有这么多人回,我发了这么多比这还有挑战性的帖子,你们都不回,是存储过程的,以后请不要这样重女轻男了,各位大侠Top

17 楼anqiant(许留心)回复于 2003-05-03 15:20:12 得分 0

to:loveyou1234(fuck)    
  我昨天帮你答的两个问题,你都还没给我分呢,你到底想怎样?  
  Top

18 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:23:39 得分 0

sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
   
  我有个想法。  
   
  for   i=1   to   xuesheng_totals  
   
  for   j=1   to   kecheng_totals  
   
  sql="select   fenshu   from   temp   where   xingming=XXXXX   and   kecheng=XXXXXX"  
  set   rs00=newconn.execute(sql)  
  if   not   rs.eof   then  
  sql="update   temp3   set   XXXX=rs("fenshu")  
  else  
  sql="update   temp3   set   XXXX='X'  
  end   if  
  newconn.execute(sql)  
   
  rs.close  
  set   rs=nothing  
  rs00.close  
  set   rs00=nothing  
   
   
  next  
   
  next  
   
  问题是:不知道怎么动态的修改字段及字段的值。  
  哎,还不如用数组的好!Top

19 楼anqiant(许留心)回复于 2003-05-03 15:23:45 得分 10

<%  
  '先定义一个数组  
  dim   a()  
  '首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof  
          while   not   rs.eof                       '如果游标没到底,也就是记录没到最后一条的话,就执行  
                  '打开temp3进行添加  
                  set   rs01=server.createObject("adodb.recordset")  
                  sql="Select   *   From   temp3"  
                  rs01.open   sql,conn,1,3  
   
                  a=rs01.fieldscount-3  
                  for   i=1   to   a  
                          '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
                          sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
                          set   rs02=newconn.execute(sql)  
                          '循环执行查询将成绩付给数组  
                          if   rs02.eof   and   rs02.bof  
                                  a(i)="x"  
                          else  
                                  redim   a(rs01.fieldscount-2)       '重定义数组  
                                  a(i)=rs02("fenshu")  
                          end   if  
   
                  next  
                  rs02.close  
                  set   rs02=nothing  
                  '循环添加记录  
                  rs01.addnew  
                  rs01("姓名")=rs("xingming")  
                  i=1  
                  while   not   i>a  
                          rs01(rs01(i).name)=a(i)  
                          b=b+a(i)  
                          i=i+1  
                  wend  
                  c=b/a  
                  rs01("总分")=b  
                  rs01("平均分")=c  
   
                  rs01.update  
                  rs01.close  
                  set   rs01=nothing  
   
                  rs.movenext  
          wend  
  end   if  
  rs.close  
  set   rs=nothing  
   
  %>  
   
   
  你试试看,不行我再改,我才睡了午觉起来,春梦了无痕。Top

20 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:31:05 得分 0

vb编译错误   Microsoft   VBScript   运行时错误   (0x800A01B6  
  整块修改吧,我整块拷贝,免得出什么以外   差错。  
  <%  
  dim   a()  
  '首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof   then  
  while   not   rs.eof  
  '打开temp3进行添加  
  set   rs01=server.createObject("adodb.recordset")  
  sql="Select   *   From   temp3"  
  rs01.open   sql,newconn,1,3  
  for   i=1   to   rs01.Fields.Count-3  
  '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
  sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
  set   rs02=newconn.execute(sql)  
  '循环执行查询将成绩付给数组  
  if   rs02.eof   and   rs02.bof   then  
  a(i)="x"  
  else  
  redim   a(rs01.fieldscount-2)       '重定义数组  
   
  here   wrong  
   
   
   
                                  a(i)=rs02("fenshu")  
  end   if  
   
  next  
  rs02.close  
  set   rs02=nothing  
  '循环添加记录  
  rs01.addnew  
  rs01("姓名")=rs("xingming")  
  i=1  
  while   i>a  
  rs01(rs01(i).name)=a(i)  
  b=b+a(i)  
  i=i+1  
  wend  
  c=b/a  
  rs01("总分")=b  
  rs01("平均分")=c  
   
  rs01.update  
  rs01.close  
  set   rs01=nothing  
   
  rs.movenext  
  wend  
  end   if  
  rs.close  
  set   rs=nothing  
  %>  
  Top

21 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:33:43 得分 0

我用的是这个  
  for   i=1   to   rs01.Fields.Count-3  
  而不是这个  
  a=rs01.fieldscount-3  
                  for   i=1   to   a  
  你怎么都用a啊,可以用相同的变量?Top

22 楼anqiant(许留心)回复于 2003-05-03 15:41:32 得分 0

你用我的吧,不然  
  while   i>a  
  出错  
   
  我的a是一般变量,a()是数组变量,不一样的.Top

23 楼anqiant(许留心)回复于 2003-05-03 15:44:07 得分 0

把  
  a=rs01.fieldscount-3  
  改成  
  a=rs01.Fields.Count-3Top

24 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:44:38 得分 0

sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
   
  请问,如何来识别rs01(i).name???  
  我总觉得这儿没对。。。  
  字段名可以这样提去出来吗?rs01(1).name,rs01(2).name,?  
  rs01是一个数组还是怎么回事?  
   
  恩,这里太长了,不如去  
  http://expert.csdn.net/Expert/topic/1734/1734883.xml?temp=.9603845  
  继续讨论我们的问题吧?Top

25 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:46:26 得分 0

好,我用你的。呵呵,Top

26 楼yangyanli(乌托邦主·蛤蟆)回复于 2003-05-03 15:52:38 得分 0

Microsoft   VBScript   运行时错误   (0x800A000D)  
  /asp/xsgl/quest10.asp,   第   54   行  
   
  恩,这个就是你的,修改了几个小错误,语法和拼写错误。  
   
  <%  
  '先定义一个数组  
  dim   a()  
  '首先把姓名查出来  
  sql="select   xingming   from   temp1"  
  set   rs=newconn.execute(sql)  
  if   not   rs.eof   and   not   rs.bof   then  
          while   not   rs.eof                       '如果游标没到底,也就是记录没到最后一条的话,就执行  
                  '打开temp3进行添加  
                  set   rs01=server.createObject("adodb.recordset")  
                  sql="Select   *   From   temp3"  
                  rs01.open   sql,newconn,1,3  
   
                  a=rs01.fields.count-3     '''///////////////////here,wrong  
   
   
  出错了。  
   
   
   
   
   
                  for   i=1   to   a  
                          '同过temp1查出的姓名和temp3的字段名查询出temp的成绩  
                          sql="select   fenshu   from   temp   where   xingming='"&rs("xingming")&"'   and   kecheng='"&rs01(i).name&"'"  
                          set   rs02=newconn.execute(sql)  
                          '循环执行查询将成绩付给数组  
                          if   rs02.eof   and   rs02.bof   then  
                                  a(i)="x"  
                          else  
                                  redim   a(rs01.fields.count-2)       '重定义数组  
                                  a(i)=rs02("fenshu")  
                          end   if  
   
                  next  
                  rs02.close  
                  set   rs02=nothing  
                  '循环添加记录  
                  rs01.addnew  
                  rs01("姓名")=rs("xingming")  
                  i=1  
                  while   not   i>a  
                          rs01(rs01(i).name)=a(i)  
                          b=b+a(i)  
                          i=i+1  
                  wend  
                  c=b/a  
                  rs01("总分")=b  
                  rs01("平均分")=c  
   
                  rs01.update  
                  rs01.close  
                  set   rs01=nothing  
   
                  rs.movenext  
          wend  
  end   if  
  rs.close  
  set   rs=nothing  
   
  %>  
  Top

27 楼anqiant(许留心)回复于 2003-05-03 16:29:12 得分 0

好的,我的QQ:149066794Top

28 楼johnsuna(缘来是e)回复于 2003-05-03 16:46:38 得分 0

见到MM的问题个个的回复都非常积极!Top

相关问题

  • 好漂亮的小女子!
  • 小女子初来乍到
  • 小女子虚心求教!
  • 小女子菜,请各位高手帮一下小女子我!!!!
  • 课程设计,痛苦哦,哥哥们帮帮小女子解决一个小问题,先谢了啊
  • 快来帮帮小女子的忙
  • 急!小女子请教大家了!
  • 小女子有个问题请教?
  • 小女子初学求教VC++
  • 帮帮忙,小女子欲哭无泪

关键词

  • mp3
  • 字段
  • 总分
  • 数学
  • 查询
  • vbscript
  • 修改
  • rs
  • kecheng
  • xingming

得分解答快速导航

  • 帖主:yangyanli
  • anqiant

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo