zoukankan      html  css  js  c++  java
  • DOM--sql server

     1    public List<LianHeData> select(int ID)
     2         {
     3             List<LianHeData> list = new List<LianHeData>();
     4             conn.Open();
     5             cmd = conn.CreateCommand();
     6                 //*************************************************************************************************
     7             cmd.CommandText = "select a.Name name1,b.Name name2,c.Name name3 from Users a,Nation b,Clas c where a.ClassCode=b.Code and a.NationCode=c.Code and a.ID=@ID";
    //**********************************************************************************************
    8 cmd.Parameters.Clear(); 9 //放入到缓存中 10 cmd.Parameters.Add("@ID", ID); 11 SqlDataReader dr = cmd.ExecuteReader(); 12 13 while (dr.Read()) 14 { 15 LianHeData data = new LianHeData(); 16 data.Name11 = dr["name1"].ToString(); 17 data.Name21 = dr["name2"].ToString(); 18 data.Name31 = dr["name3"].ToString(); 19 //data.ID1 = int.Parse(dr["ID"].ToString()); 20 //data.Name1 = dr["Name"].ToString(); 21 //data.PWD1 = dr["PWD"].ToString(); 22 //data.QuanXian1 = int.Parse(dr["QuanXian"].ToString()); 23 //data.NationCode1 = int.Parse(dr["NationCode"].ToString()); 24 //data.ClassCode1 = int.Parse(dr["ClassCode"].ToString()); 25 list.Add(data); 26 27 } 28 return list; 29 30 }

    "select a.Name,b.Name,c.Name from Users a,Nation b,Clas c where a.ClassCode=b.Code and a.NationCode=c.Code and a.ID=@ID"是查不出数据的  

    必须定一个定量“select a.Name name1,b.Name name2,c.Name name3 from Users a,Nation b,Clas c where a.ClassCode=b.Code and a.NationCode=c.Code and a.ID=@ID”

  • 相关阅读:
    【游戏开发】Excel表格批量转换成CSV的小工具
    iOS
    iOS
    Xcode
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
  • 原文地址:https://www.cnblogs.com/hanke123/p/5257501.html
Copyright © 2011-2022 走看看