select * from Inquiry1 where title like '"+this.textbox.Text+"' UNION ALL select * from Inquiry2 where title like '"+this.textbox.Text+" 我是这样情况,我查出这些数据后,我要点他的时候传ID到另一个页面,另一个页面根据ID开始赋值,现在另一个页面接受ID的时候不知道是哪个表的!
我怎么判断其中一条是哪个表里的 ? 这两个表有是完全相同的,就是数据不同, 他们都有一个列Type 这列写着他是什么表.麻烦各位了, 请写详细点 谢谢

解决方案 »

  1.   

    传ID的时候顺便传Type 过去不就可以了?
      

  2.   

    把Type 这个字段也可以当成参数传到另外的页面啊
      

  3.   


    楼上有道理,可以将查询语句作下修改:
    select *,type=1 from Inquiry1 where title like '"+this.textbox.Text+"' 
    UNION ALL 
    select *,type=2 from Inquiry2 where title like '"+this.textbox.Text+" 
    然后在接受页面,根据type的值就知道查哪个表了。。
      

  4.   

    或者直接传表名也可以。。
    select *,tablename='Inquiry1' from Inquiry1 where title like '"+this.textbox.Text+"' 
    UNION ALL 
    select *,tablename='Inquiry2' from Inquiry2 where title like '"+this.textbox.Text+" 
      

  5.   

    怎么直接传表名? 
    <%# Eval("ID", "Answer.aspx?id={0}") %>   我传值  是这样 ,怎么传2个值
      

  6.   

    <%# Eval("ID", "Answer.aspx?id={0}") %>
    我现在是传1个ID ,  要传2个  把TYPE 也传过去  该怎么写?
      

  7.   

    Answer.aspx?id=<%# Eval("ID") %>&type=<%# Eval("Type") %>
      

  8.   

    给你说个笨方法 select * ,'Inquiry1_'+Convert(Varchar(10),UserID) AS FROMTABLE from Inquiry1 where title like '"+this.textbox.Text+"' 
    UNION ALL 
    select * ,'Inquiry2_'+Convert(Varchar(10),UserID) AS FROMTABLE from Inquiry2 where title like '"+this.textbox.Text+"  Eval("FROMTABLE", "Answer.aspx?id={0}") %>  
    你获取到是  "Inquiry1_1"  切分字符串  
    String.Split("_")[0] =="Inquiry1"
     String.Split("_")[1] =="1"
    不就好了.
      

  9.   


    接受值页面  代码该怎么写? 接受Type 然后看这个值 去查是哪个表
      

  10.   


    你也真够懒得了!!string strType = Request.QueryString["type"]
    string strID = Request.QueryString["id"]if (strType =="Inquiry1")
    {
    查询Inquiry1表
    }
    else if(strType=="Inquiry2")
    {
    查询Inquiry2表
    }
      

  11.   


    Type值是表名还是其它?Page_Load(...)
    {
    string id=Request["id"];
    string type = Request["type"];
    string tablename = "";
    if(type == "?")
    {
    tablename = ?;
    }
    //...
    if(tablename=="")
    {
    Response.End();
    }
    string strsql = "select * from "+tablename+" where id="+id;
    //查了
    }
      

  12.   


    string strType = Request.QueryString["type"] 
    strType = "领奖�"   为什么最后一个字显示不出来 ?? 正确应该是 领奖类
      

  13.   

    Answer.aspx?id= <%# Eval("ID") %>&type= <%# Server.UrlEncode(Eval("Type").ToString()) %>