本文介绍了显示客户表清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在数据库中显示客户列表,但是发生了错误.请帮帮我!
错误:
指定的演员表无效.
代码:
Hi,
I want to to display list of customers in my database but an error has occurred. Please help me!
error:
Specified cast is not valid.
code:
public Clients ConsultationClient(int ID_CLIENT)
{
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
conn.ConnectionString = @"Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=topnet;Initial Catalog=TopnetBase;Data Source=SWEET-4B6F892B4\SQLEXPRESS";
Clients oClients = new Clients();
ClientTopNet oClient = new ClientTopNet();
conn.Open();
System.Data.OleDb.OleDbDataReader rs;
System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand("select * from client where ID_CLIENT=''" + ID_CLIENT + "''", conn);
rs = comm.ExecuteReader();
while (rs.Read())
{
oClient.ID_CLIENT = rs.GetInt32(0) ;
oClient.LOGIN_CREATION = rs.GetString(1);
oClient.DATE_CREATION = rs.GetDateTime(2);
oClient.LOGIN_MODIFICATION = rs.GetString(3);
oClient.DATE_MODIFICATION = rs.GetDateTime(4);
oClient.TYPE_CLIENT = rs.GetInt32(5);
oClient.CIVILITE = rs.GetInt32(6);
oClient.NOM = rs.GetString(7);
oClient.PRENOM = rs.GetString(8);
oClient.FONCTION = rs.GetString(9);
oClient.RS = rs.GetString(10);
oClient.CIN = rs.GetString(11);
oClient.ADRESSE = rs.GetString(12);
oClient.VILLE = rs.GetString(13);
oClient.CP = rs.GetInt32(14);
oClient.GOUVERN = rs.GetInt32(15);
oClient.TEL = rs.GetString(16);
oClient.GSM = rs.GetString(17);
oClient.FAX = rs.GetString(18);
oClient.EMAIL = rs.GetString(19);
oClient.CD_ORIGINE = rs.GetInt32(20);
oClient.OBSERV = rs.GetString(21);
oClient.EXONERE = rs.GetInt32(22);
oClient.EXOTIMBRE = rs.GetInt32(23);
oClient.SECTEUR_ACT = rs.GetInt32(24);
oClient.VIP = rs.GetInt32(25);
oClient.CHARGECOMPTE = rs.GetString(26);
oClient.CHARGECOMPTE_RD = rs.GetString(27);
oClient.CATEGORIE = rs.GetInt32(28);
oClient.REGISTRE = rs.GetString(29);
oClient.METHOD_ENVOI_FACT = rs.GetInt32(30);
oClient.PERSONNEL = rs.GetInt32(31);
oClient.REF_CLIENTCRM = rs.GetString(32);
oClients.Add(oClient);
}
rs.Close();
conn.Close();
return oClients;
}
推荐答案
这篇关于显示客户表清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!