Hi,
Using the table Below, i'm triying to select the list of interfaces whose port number is 300310901.
Code:
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| Port | int(9) | | PRI | 0 | |
| IP | varchar(15) | | PRI | | |
| Masque | varchar(15) | YES | | NULL | |
| PortsOuverts | varchar(255) | YES | | NULL | |
| Subnet | smallint(6) | | MUL | -1 | |
| Nom | varchar(50) | YES | | NULL | |
| Domaine | varchar(50) | YES | | NULL | |
| DHCP | tinyint(1) | YES | | 1 | |
| DNSPrimaire | varchar(15) | YES | | NULL | |
| DNSSecondaire | varchar(15) | YES | | NULL | |
| Passerelle | varchar(15) | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
This is the function that i m using :
Code:
public ArrayList SelectionInt(int ident,string query)
{
try
{
Configuration cfg = new Configuration();
cfg.AddXmlFile("D:\\Mappfile1\\Interface.hbm.xml");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
//IList list1 = session.Find("from Port where id<6");
//IList list1 = session.Find(query+ident);
IList list1 = session.Find("select * from Interface where port=300310901");
//IList list1 = session.Find("from Interface where nom = 'print-srv'");
//Query q1 = session.CreateQuery("from Interface where nom = 'print-srv'");
//ScrollableResults interf = q1.scroll();
//session.Flush ();
ArrayList list = new ArrayList();
foreach(Interface interf in list1)
{
list.Add(interf);
}
session.Close();
return list;
}
catch (System.Exception ex) { Console.WriteLine(ex.Message); }
return null;
}
The problem is that i don't get the right result (the same as when i execute query directly in the database) so when i execute the query on the database i got the following result :
Code:
+----------------+
| IP |
+----------------+
| 192.168.10.160 |
| 192.168.12.160 |
| 192.168.14.160 |
| 192.168.2.160 |
| 192.168.3.160 |
| 192.168.4.160 |
| 192.168.5.160 |
| 192.168.6.160 |
| 192.168.7.160 |
+----------------+
but via Nhibernate i get :
Code:
192.168.10.160
192.168.10.160
192.168.10.160
192.168.10.160
192.168.10.160
192.168.10.160
192.168.10.160
192.168.10.160
192.168.10.160
Nine time the first line.
Please can some one help me. I m availble for any more detail.
Thank u in advance