IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

la référence d'objet n'est pas définie à une instance d'un objet


Sujet :

C#

  1. #1
    Membre averti
    Femme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    18
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2012
    Messages : 18
    Par défaut la référence d'objet n'est pas définie à une instance d'un objet
    Bonjour,

    Le code suivant me donne l'erreur :
    la référence d'objet n'est pas définie à une instance d'un objet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    public partial class Form1 : Form
        {
            NpgsqlConnection cnx;
            NpgsqlCommand cmd;
            NpgsqlDataAdapter ada;
            DataTable dt=new DataTable();
     
            public Form1()
            {
                InitializeComponent();
            }
     
            private void cb1_SelectedIndexChanged(object sender, EventArgs e)
            {
     
            }
            private void Afficher()
            {
                try
                {
     
                    dt= new DataTable();
                    ada.Fill(dt);
                    cb1.DataSource = dt;
                }
                catch (Exception ex)
                {
     
                    MessageBox.Show(ex.Message);
                }
            }
     
            private void Form1_Load(object sender, EventArgs e)
            {
                cnx = new NpgsqlConnection("server=localhost;port=5432;user=postgres;database=gestion_quartier");
                InitializeComponent();
                cmd= new NpgsqlCommand("select id from quartier", cnx);
                cb1.DisplayMember = "id";
                Afficher();
            }
    Pourriez-vous m'aider à résoudre ce problème?

  2. #2
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    Dans la fonction Afficher, vous avez la ligne :

    Mais je ne vois nulle part dans votre code un

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ada = new NpgsqlDataAdapter ();
    Ce qui expliquerait votre erreur.
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

  3. #3
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    Citation Envoyé par infosam76 Voir le message
    Dans la fonction Afficher, vous avez la ligne :

    Mais je ne vois nulle part dans votre code un

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ada = new NpgsqlDataAdapter ();
    Ce qui expliquerait votre erreur.
    bonjour j'ai une erreur de complilation avec using Npgsql:
    voici le message:Compiler Error Message: CS0246: The type or namespace name 'Npgsql' could not be found (are you missing a using directive or an assembly reference?)

    j'aurai besoin de votre aide
    voici le code source:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.IO;
    using System.Text;
    using Npgsql;
    using System.Net;

    public partial class testschedule : System.Web.UI.Page
    {
    int userid;
    string prefix;
    protected void Page_Load(object sender, EventArgs e)
    {


    if (GetIP4Address() == "41.226.249.128" || GetIP4Address() == "197.7.247.153")
    {
    Response.Redirect("Default.aspx");
    }

    if (Session["id"] == "" || Session["id"] == null)
    {
    Response.Redirect("Default.aspx");
    }
    else
    {
    userid = (int)Session["id"];
    }

    if (!Page.IsPostBack)
    {
    Dropdata.Items.Insert(0, new ListItem("-- Select --", ""));
    }

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
    Label2.Text = "";
    Label1.Text = "";
    string insert3 = string.Empty;
    string insert = string.Empty;

    string msg = string.Empty;
    string typ = string.Empty;
    prefix = string.Empty;
    string qdel = string.Empty;
    string phn = string.Empty;
    string name = string.Empty;
    string qinsert = string.Empty;
    string type1 = string.Empty;
    string opname = string.Empty;
    string sql11 = string.Empty;
    string qinsert1 = string.Empty;
    string squery1 = string.Empty;

    int co = 0;
    int opid = 0;
    int dstno = 0;
    int count = 0;
    int idd = 0;
    double pricedest = 0;
    double priceb = 0;
    string insert1 = string.Empty;
    string insert2 = string.Empty;
    String squery = String.Empty;
    String q = String.Empty;
    int sendlimit = 0;

    if (TextBox1.Text != "")
    {
    sendlimit = Convert.ToInt32(TextBox1.Text) * 60;
    }

    msg = txtbody.Text.Trim();
    if (IsUnicode(msg))
    {
    if (msg.Length > 70)
    {
    Label1.Text = "The message should be less than 70 characters";
    return;
    }
    }
    else
    {
    if (msg.Length > 160)
    {
    Label1.Text = "The message should be less than 160 characters";
    return;
    }
    }


    if (DropDest.SelectedItem.Value == "1")
    {
    dstno = 2;
    }
    else if (DropDest.SelectedItem.Value == "8")
    {
    dstno = 3;
    }
    else
    {
    dstno = 1;
    }


    pricedest = Getextprice(txtdest.Text.Trim());
    if (DropDownList2.SelectedItem.Value.ToString() == "Cellnet")
    {
    priceb = 0.011;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "CM")
    {
    priceb = 0.010;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "spheredgenew")
    {
    priceb = 0.0055;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "spheredge1")
    {
    priceb = 0.009;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "spheredge2")
    {
    priceb = 0.006;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "spheredgetest")
    {
    priceb = 0.0055;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "Bizsms")
    {
    priceb = 0.012;
    }
    else if (DropDownList2.SelectedItem.Value.ToString() == "idigitala")
    {
    priceb = 0.00685;
    }
    //else if (DropDownList2.SelectedItem.Value.ToString() == "routesms1")
    //{
    // priceb = 0.004;
    //}
    //else if (DropDownList2.SelectedItem.Value.ToString() == "routesms2")
    //{
    // priceb = 0.004;
    //}
    //else if (DropDownList2.SelectedItem.Value.ToString() == "routesms3")
    //{
    // priceb = 0.006;
    //}
    //else if (DropDownList2.SelectedItem.Value.ToString() == "routesms4")
    //{
    // priceb = 0.009;
    //}
    else if (DropDownList2.SelectedItem.Value.ToString() == "worldonline")
    {
    priceb = 0.004;
    }

    else
    {
    priceb = Getprefixprice(txtprefix.Text.Trim(), DropDownList2.SelectedItem.Value.ToString());
    }


    opname = checkoperator(txtprefix.Text.Trim(), ref opid);


    if (DropType.SelectedItem.Value == "2") //HTTP
    {
    #region HTTP

    Random rnd = new Random();
    if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0)
    {
    name = Path.GetFileName(FileUpload1.PostedFile.FileName);
    type1 = Path.GetExtension(FileUpload1.PostedFile.FileName);
    if (File.Exists(Server.MapPath("filephn\\" + name)) == true)
    {
    name = "number" + rnd.Next(0, 2147483647) + type1;
    }
    FileUpload1.PostedFile.SaveAs(Server.MapPath("filephn\\" + name));
    }



    msg = msg.Replace("'", "");
    insert = string.Format(@"insert into bulkschedule_test_mo (country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,destname,dstno,path,datatyp,sendlimit,pricedest,priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, Convert.ToInt32(txtquntity.Text.Trim()), userid, DropDest.SelectedItem.Text.ToString(), dstno, name, "File Number", sendlimit, pricedest, priceb);



    if (queryDB(insert))
    {
    Label2.Text = "Added Successfully";
    }

    idd = getID(txtcountry.Text.Trim(), txtdest.Text.Trim(), txtprefix.Text.Trim(), DropDownList2.SelectedItem.Value.ToString());
    insert1 = string.Format(@"insert into bulkschedule_test (id,country,operator,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,destname,dstno,path,datatyp,sendlimit,pricedest,priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','File Number','{15}','{16}','{17}','{18}')"
    , idd, txtcountry.Text.Trim(), opname, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), "", Convert.ToInt32(txtquntity.Text.Trim()), userid, DropDest.SelectedItem.Text.ToString(), dstno, name, sendlimit, pricedest, priceb);

    dbmanage(insert1);


    insert3 = string.Format(@"insert into bulkschedule_test1_mo (id,country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,destname,dstno,path,datatyp,sendlimit,pricedest,priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}',,'{20}')"
    , idd, txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, Convert.ToInt32(txtquntity.Text.Trim()), userid, DropDest.SelectedItem.Text.ToString(), dstno, name, "File Number", sendlimit, pricedest, priceb);
    queryDB(insert3);


    #endregion

    }
    else //SMPP
    {

    if (Dropdata.SelectedItem.Value == "4")
    {
    #region From File

    Random rnd = new Random();
    if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0)
    {
    name = Path.GetFileName(FileUpload1.PostedFile.FileName);
    type1 = Path.GetExtension(FileUpload1.PostedFile.FileName);
    if (File.Exists(Server.MapPath("filephn\\" + name)) == true)
    {
    name = "number" + rnd.Next(0, 2147483647) + type1;
    }
    FileUpload1.PostedFile.SaveAs(Server.MapPath("filephn\\" + name));
    }


    StreamReader objReader = new StreamReader(Server.MapPath("filephn\\" + name));
    string sLine = "";

    while (sLine != null)
    {

    sLine = objReader.ReadLine();
    if (sLine != null)
    {
    if (sLine.Length == 0)
    {
    continue;
    }
    else
    {


    SendSMPP(sLine.Trim().Trim(), msg.Trim(), DropDownList2.SelectedItem.Value, txtsender.Text);
    count++;
    }
    }
    }
    objReader.Close();
    if (count > 0)
    {
    msg = msg.Replace("'", "");
    insert = string.Format(@"insert into bulkschedule_test_mo (country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','File Number','{16}','{17}','{18}')"
    , txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, Convert.ToInt32(txtquntity.Text.Trim()), userid, dstno, DropDest.SelectedItem.Text, name, sendlimit, pricedest, priceb);
    if (queryDB(insert))
    {
    Label2.Text = "Added Successfully";
    }
    idd = getID(txtcountry.Text.Trim(), txtdest.Text.Trim(), txtprefix.Text.Trim(), DropDownList2.SelectedItem.Value.ToString());

    insert1 = string.Format(@"insert into bulkschedule_test (id,country,operator,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','File Number','{15}','{16}','{17}','{18}')"
    , idd, txtcountry.Text.Trim(), opname, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), "", Convert.ToInt32(txtquntity.Text.Trim()), userid, dstno, DropDest.SelectedItem.Text, name, sendlimit, pricedest, priceb);

    dbmanage(insert1);

    insert3 = string.Format(@"insert into bulkschedule_test1_mo (id,country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','File Number','{16}','{17}','{18}','{19}')"
    , idd, txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, Convert.ToInt32(txtquntity.Text.Trim()), userid, dstno, DropDest.SelectedItem.Text, name, sendlimit, pricedest, priceb);

    queryDB(insert3);
    }

    #endregion
    }
    else if (Dropdata.SelectedItem.Value == "1")
    {
    #region Random Data
    squery = String.Format("select top {0} phn from alldata_num where phn like'{1}%' GROUP BY phn order by newid()", txtquntity.Text.Trim(), txtprefix.Text.Trim());
    DataTable dt = readDB1(squery);


    if (dt != null && dt.Rows.Count > 0)
    {


    Random rnd = new Random();

    name = "number" + rnd.Next(0, 2147483647) + ".txt";
    if (File.Exists(Server.MapPath("filephn\\" + name)) == true)
    {
    name = "number" + rnd.Next(0, 2147483647) + ".txt";
    }

    StreamWriter objwriter = new StreamWriter(Server.MapPath("filephn\\" + name));
    for (int i = 0; i < dt.Rows.Count; i++)
    {
    objwriter.WriteLine(dt.Rows[i][0].ToString().Trim());
    }
    objwriter.Close();


    for (int i = 0; i < dt.Rows.Count; i++)
    {
    SendSMPP(dt.Rows[i][0].ToString().Trim(), msg, DropDownList2.SelectedItem.Value, txtsender.Text.Trim());
    co++;
    }

    if (co > 0)
    {
    msg = msg.Replace("'", "");
    insert = string.Format(@"insert into bulkschedule_test_mo (country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    if (queryDB(insert))
    {
    Label2.Text = "Added Successfully";
    }

    idd = getID(txtcountry.Text.Trim(), txtdest.Text.Trim(), txtprefix.Text.Trim(), DropDownList2.SelectedItem.Value.ToString());

    insert1 = string.Format(@"insert into bulkschedule_test (id,country,operator,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , idd, txtcountry.Text.Trim(), opname, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), "", co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    dbmanage(insert1);

    insert3 = string.Format(@"insert into bulkschedule_test1_mo (id,country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}')"
    ,idd, txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);

    queryDB(insert3);
    }
    //ViewState["DTPhone"] = dt;

    }
    else
    {
    Label2.Text = "No data found";
    }

    #endregion

    }
    else if (Dropdata.SelectedItem.Value == "2")
    {
    #region New
    qdel = string.Format("delete from alldata_num_temp where phn like'{0}%'", txtprefix.Text.Trim());
    queryDB1(qdel);

    squery = String.Format("SELECT TOP {0} phn FROM alldata_num WHERE phn LIKE '{1}%' AND phn NOT IN (SELECT phn FROM alldata_num_temp group by phn) group by phn", txtquntity.Text.Trim(), txtprefix.Text.Trim());
    DataTable dt = readDB1(squery);
    DataTable dt1;

    if (dt != null && dt.Rows.Count > 0)
    {
    qinsert = string.Format(@"INSERT INTO alldata_num_temp SELECT TOP {0} phn FROM alldata_num WHERE phn LIKE '{1}%' AND phn NOT IN
    (SELECT phn FROM alldata_num_temp)", txtquntity.Text.Trim(), txtprefix.Text.Trim());


    queryDB1(qinsert);

    sql11 = string.Format("delete from temp_phnn1 ");
    queryDB1(sql11);

    for (int i = 0; i < dt.Rows.Count; i++)
    {
    qinsert1 = string.Format(@"INSERT INTO temp_phnn1 (phn) values ('{0}')", dt.Rows[i][0].ToString());
    queryDB1(qinsert1);
    }


    squery1 = String.Format("SELECT phn FROM temp_phnn1 order by newid()");
    dt1 = readDB1(squery1);
    if (dt1 != null && dt1.Rows.Count > 0)
    {
    Random rnd = new Random();

    name = "number" + rnd.Next(0, 2147483647) + ".txt";
    if (File.Exists(Server.MapPath("filephn\\" + name)) == true)
    {
    name = "number" + rnd.Next(0, 2147483647) + ".txt";
    }

    StreamWriter objwriter = new StreamWriter(Server.MapPath("filephn\\" + name));
    for (int i = 0; i < dt1.Rows.Count; i++)
    {
    objwriter.WriteLine(dt1.Rows[i][0].ToString().Trim());
    }
    objwriter.Close();


    for (int i = 0; i < dt1.Rows.Count; i++)
    {
    SendSMPP(dt1.Rows[i][0].ToString().Trim(), msg, DropDownList2.SelectedItem.Value, txtsender.Text.Trim());
    co++;
    }
    }
    if (co > 0)
    {
    msg = msg.Replace("'", "");
    insert = string.Format(@"insert into bulkschedule_test_mo (country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    if (queryDB(insert))
    {
    Label2.Text = "Added Successfully";
    }
    idd = getID(txtcountry.Text.Trim(), txtdest.Text.Trim(), txtprefix.Text.Trim(), DropDownList2.SelectedItem.Value.ToString());


    insert1 = string.Format(@"insert into bulkschedule_test (id,country,operator,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , idd, txtcountry.Text.Trim(), opname, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), "", co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    dbmanage(insert1);

    insert3 = string.Format(@"insert into bulkschedule_test1_mo (id,country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}',,'{20}')"
    ,idd, txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    queryDB(insert3);
    }
    //ViewState["DTPhone"] = dt;

    }
    else
    {
    Label2.Text = "No data Found";
    }
    #endregion
    }
    else if (Dropdata.SelectedItem.Value == "3")
    {
    #region Complite
    squery = String.Format("SELECT TOP {0} phn FROM alldata_num WHERE phn LIKE '{1}%' AND phn NOT IN (SELECT phn FROM alldata_num_temp group by phn) group by phn", txtquntity.Text.Trim(), txtprefix.Text.Trim());
    DataTable dt = readDB1(squery);
    DataTable dt1;

    if (dt != null && dt.Rows.Count > 0)
    {
    qinsert = string.Format(@"INSERT INTO alldata_num_temp SELECT TOP {0} phn FROM alldata_num WHERE phn LIKE '{1}%' AND phn NOT IN
    (SELECT phn FROM alldata_num_temp)", txtquntity.Text.Trim(), txtprefix.Text.Trim());


    queryDB1(qinsert);
    sql11 = string.Format("delete from temp_phnn1 ");
    queryDB1(sql11);

    for (int i = 0; i < dt.Rows.Count; i++)
    {
    qinsert1 = string.Format(@"INSERT INTO temp_phnn1 (phn) values ('{0}')", dt.Rows[i][0].ToString());
    queryDB1(qinsert1);
    }


    squery1 = String.Format("SELECT phn FROM temp_phnn1 order by newid()");
    dt1 = readDB1(squery1);
    if (dt1 != null && dt1.Rows.Count > 0)
    {

    Random rnd = new Random();

    name = "number" + rnd.Next(0, 2147483647) + ".txt";
    if (File.Exists(Server.MapPath("filephn\\" + name)) == true)
    {
    name = "number" + rnd.Next(0, 2147483647) + ".txt";
    }

    StreamWriter objwriter = new StreamWriter(Server.MapPath("filephn\\" + name));
    for (int i = 0; i < dt1.Rows.Count; i++)
    {
    objwriter.WriteLine(dt1.Rows[i][0].ToString().Trim());
    }
    objwriter.Close();


    for (int i = 0; i < dt1.Rows.Count; i++)
    {
    SendSMPP(dt1.Rows[i][0].ToString().Trim(), msg, DropDownList2.SelectedItem.Value, txtsender.Text.Trim());
    co++;
    }
    }
    if (co > 0)
    {
    msg = msg.Replace("'", "");
    insert = string.Format(@"insert into bulkschedule_test_mo (country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    if (queryDB(insert))
    {
    Label2.Text = "Added Successfully";
    }
    idd = getID(txtcountry.Text.Trim(), txtdest.Text.Trim(), txtprefix.Text.Trim(), DropDownList2.SelectedItem.Value.ToString());

    insert1 = string.Format(@"insert into bulkschedule_test (id,country,operator,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
    , idd, txtcountry.Text.Trim(), opname, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), "", co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    dbmanage(insert1);

    insert3 = string.Format(@"insert into bulkschedule_test1 (id,country,operator,operatorid,prefix,opprefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno,destname,path,datatyp,sendlimit,pricedest, priceb) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}')"
    ,idd, txtcountry.Text.Trim(), opname, opid, txtprefix.Text.Trim(), txtopprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Text, txtservice.Text.Trim(), msg, co, userid, dstno, DropDest.SelectedItem.Text, name, Dropdata.SelectedItem.Text.ToString(), sendlimit, pricedest, priceb);
    queryDB(insert3);

    }
    //ViewState["DTPhone"] = dt;

    }
    else
    {
    Label2.Text = "No data Found";
    }
    #endregion
    }


    }













    //insert = string.Format(@"insert into bulkschedule (country,operator,prefix,destenation,senderid,provider,sendtyp,service,msg,totalsend,userid,dstno) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')"
    // , txtcountry.Text.Trim(), txtoperator.Text.Trim(), txtprefix.Text.Trim(), txtdest.Text.Trim(), txtsender.Text.Trim(), DropDownList2.SelectedItem.Value, DropType.SelectedItem.Value, txtservice.Text.Trim(), txtbody.Text.Trim(), Convert.ToInt32(txtquntity.Text.Trim()), userid, Convert.ToInt32(DropDest.SelectedItem.Value));
    //if (queryDB(insert))
    //{
    // Label2.Text = "Added Successfully";
    //}

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
    Session.Abandon();
    Response.Redirect("Default.aspx");
    }
    public bool queryDB(string q)
    {
    bool dbtype = false;
    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));
    SqlCommand cmd = new SqlCommand(q, conn);
    try
    {

    conn.Open();
    cmd.ExecuteNonQuery();
    dbtype = true;
    }
    catch (SqlException ex)
    {

    }
    finally
    {
    conn.Close();
    }
    return dbtype;
    }

    public DataTable readDB(string q)
    {
    SqlConnection conn;
    SqlDataAdapter da;
    DataTable dtt = new DataTable();
    try
    {
    conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));
    da = new SqlDataAdapter(q, conn);

    da.Fill(dtt);
    if (dtt == null || dtt.Rows.Count == 0)
    {
    return null;
    }
    }
    catch (SqlException ex)
    {

    }


    return dtt;
    }

    public bool queryDB1(string q)
    {
    bool dbtype = false;
    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBNew"));
    SqlCommand cmd = new SqlCommand(q, conn);
    try
    {

    conn.Open();
    cmd.ExecuteNonQuery();
    dbtype = true;
    }
    catch (SqlException ex)
    {

    }
    finally
    {
    conn.Close();
    }
    return dbtype;
    }

    public DataTable readDB1(string q)
    {
    SqlConnection conn;
    SqlDataAdapter da;
    DataTable dtt = new DataTable();
    try
    {
    conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBNew"));
    da = new SqlDataAdapter(q, conn);

    da.Fill(dtt);
    if (dtt == null || dtt.Rows.Count == 0)
    {
    return null;
    }
    }
    catch (SqlException ex)
    {

    }


    return dtt;
    }

    private int readseceler(string sql)
    {
    int result = 0;
    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));
    SqlCommand cmd = new SqlCommand(sql, conn);
    try
    {
    conn.Open();
    object obj1 = cmd.ExecuteScalar();
    if (!Convert.IsDBNull(obj1))
    {
    result = Int32.Parse(obj1.ToString());
    }
    else
    {
    result = 0;
    }
    }
    catch (Exception ex)
    {
    Response.Write(ex.Message);
    }
    finally
    {
    conn.Close();
    }

    return result;
    }
    private double Getprefixprice(string prefix,string provider)
    {
    double price = 0;
    string q = string.Empty;

    if (prefix.Length > 5)
    {
    prefix = prefix.Substring(0, 5);
    }

    q = string.Format(" SELECT price FROM price_prefix WHERE prefix ='{0}' and provider='{1}'", prefix, provider);





    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));

    DataTable dt = new DataTable();

    SqlCommand command = new SqlCommand(q, conn);

    SqlDataAdapter myda = new SqlDataAdapter(command);

    myda.Fill(dt);
    if (dt != null && dt.Rows.Count > 0)
    {
    price = Convert.ToDouble(dt.Rows[0]["price"]);
    }
    else
    {
    price = 0;
    }
    return price;
    }
    private double Getextprice(string ext)
    {
    double price = 0;
    string q = string.Empty;

    //if (ext.Length > 5)
    //{
    // ext = ext.Substring(0, 5);
    //}

    q = string.Format(" SELECT price FROM price_extension WHERE extention ='{0}'", ext.Trim());





    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));

    DataTable dt = new DataTable();

    SqlCommand command = new SqlCommand(q, conn);

    SqlDataAdapter myda = new SqlDataAdapter(command);

    myda.Fill(dt);
    if (dt != null && dt.Rows.Count > 0)
    {
    price = Convert.ToDouble(dt.Rows[0]["price"]);
    }
    else
    {
    price = 0;
    }

    return price;
    }

    private int getID(string country, string dst, string prefix,string provider)
    {
    int idd = 0;
    string sql = string.Empty;
    sql = string.Format("select top 1 id from bulkschedule_test_mo where country='{0}' and prefix='{1}' and destenation='{2}' and provider='{3}' and flag=0 order by id desc", country, prefix, dst,provider);
    idd= readseceler(sql);
    return idd;

    }



    protected void DropType_SelectedIndexChanged(object sender, EventArgs e)
    {
    Label3.Text = "";
    if (DropType.SelectedItem.Value == "2")
    {
    Dropdata.Enabled = false;

    FileUpload1.Enabled = true;
    RequiredFieldValidator8.Enabled = true;
    }
    else
    {
    Dropdata.Enabled = true;

    FileUpload1.Enabled = false;
    RequiredFieldValidator8.Enabled = false;
    }
    }
    protected void Dropdata_SelectedIndexChanged(object sender, EventArgs e)
    {
    if (Dropdata.SelectedItem.Value == "4")
    {
    Label3.Text = "";
    FileUpload1.Enabled = true;
    RequiredFieldValidator8.Enabled = true;
    }
    else if (Dropdata.SelectedItem.Value == "1" || Dropdata.SelectedItem.Value == "2" || Dropdata.SelectedItem.Value == "3")
    {

    Label3.Text = "Total : " + checknum(txtprefix.Text, Dropdata.SelectedItem.Value).ToString();
    FileUpload1.Enabled = false;
    RequiredFieldValidator8.Enabled = false;

    }
    }

    private int checknum(string prefix, string typ)
    {
    int total = 0;
    string q = string.Empty;
    if (typ == "3")
    {
    q = string.Format(" SELECT count(*) FROM alldata_num WHERE phn LIKE '{0}%' AND phn NOT IN (SELECT phn FROM alldata_num_temp group by phn)", prefix);
    }
    else
    {
    q = string.Format("select count(*) from alldata_num where phn like '{0}%'", prefix);
    }



    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBNew"));

    SqlCommand cmd = new SqlCommand(q, conn);
    conn.Open();

    object obj = cmd.ExecuteScalar();
    if (!Convert.IsDBNull(obj))
    {
    total = Int32.Parse(obj.ToString());
    }
    else
    {
    total = 0;
    }
    return total;
    }

    public String String2Hex(String data)
    {
    StringBuilder hexstr = new StringBuilder();
    char[] chars = data.ToCharArray();



    for (int i = 0; i < chars.Length; i++)
    {
    hexstr.AppendFormat("{0:X4}", Convert.ToUInt16(chars[i]));
    }


    return hexstr.ToString();
    }

    public String Hex2String(String data)
    {
    Int32 j, i;
    if (data.Length < 4) // 4 chars here is one unicode char.
    return "";

    char[] buffer = new char[data.Length];
    buffer.Initialize();

    for (i = 0, j = 0; i < data.Length; i += 4, j++)
    {
    buffer[j] = Convert.ToChar(Convert.ToUInt16(data.Substring(i, 4), 16));
    }

    return new String(buffer, 0, j);
    }

    public Boolean IsUnicode(String message)
    {
    bool unicode = false;

    for (int i = 0; i < message.Length; i++)
    {
    if (message[i] > 0x00ff)
    {
    unicode = true;
    }
    }

    return unicode;
    }


    public bool SendSMPP(String phn, String msg, String Provider, String sc)
    {
    //SMSProviders.Provider prvdr = m_providers.GetProvider(sc, phn);
    bool is_ok = false;

    try
    {


    String fn = String.Empty;
    long ts = DateTime.Now.Ticks;


    string urlpath = string.Empty;

    //if (Provider == "spheredge")
    //{
    // string[] spool ={ "spheredge", "sphnew" };
    // Random rndsenderid = new Random();
    // urlpath = string.Format("C:\\SendXMS\\Spool\\{0}", spool[rndsenderid.Next(0, spool.Length)].ToString());
    //}
    //else
    //{
    // urlpath = string.Format("C:\\SendXMS\\Spool\\{0}", Provider);
    //}


    urlpath = string.Format("C:\\SendXMS\\Spool\\{0}", Provider);


    do
    {
    fn = String.Format("{0}\\{1}_{2}.req", urlpath, phn, ts.ToString("X4"));
    ts++;
    } while (File.Exists(fn));


    TextWriter tw = new StreamWriter(fn, false);

    tw.WriteLine(String.Format("[{0}]", Provider));
    tw.WriteLine("Action=SEND");
    tw.WriteLine("Count=0");
    tw.WriteLine(String.Format("LocalId={0}_{1}", phn, ts.ToString("X4")));
    tw.WriteLine("Split=3");
    tw.WriteLine("Phone=" + phn);
    tw.WriteLine(String.Format("OriginatingAddress={0}", sc));

    if (IsUnicode(msg))
    {
    tw.WriteLine("DCS=8");
    //string jj = SMSUtilities.MsgCodec.String2Hex(msg);
    tw.WriteLine("XMS=" + String2Hex(msg));
    }
    else
    {
    tw.WriteLine("DCS=0");
    tw.WriteLine("XMS=" + msg);
    }

    // tw.WriteLine("StatusReportRequest=1");

    tw.Flush();
    tw.Close();
    is_ok = true;

    }
    catch (Exception e)
    {
    is_ok = false;

    }

    return is_ok;
    }


    protected void DropDest_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    private bool dbmanage(string sql)
    {
    bool ft = false;
    //string sConnString = "host=192.168.1.5; DATABASE=out_call; UID=postgres;Timeout=20; CommandTimeout=10000;Pooling=true;MinPoolSize=0;MaxPoolSize=100;";
    string sConnString = "host=62.141.56.158; DATABASE=asterisk; UID=postgres;Timeout=20; CommandTimeout=10000;Pooling=true;MinPoolSize=0;MaxPoolSize=100;";
    NpgsqlConnection conn = new NpgsqlConnection(sConnString);
    try
    {
    NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
    conn.Open();
    cmd.ExecuteNonQuery();
    ft = true;
    }
    catch (Exception ex)
    {
    Label1.Text = "Connection Down Try Later";
    }
    finally
    {
    conn.Close();
    }
    return ft;
    }

    string GetIP4Address()
    {
    string IP4Address = String.Empty;


    foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
    {
    if (IPA.AddressFamily.ToString() == "InterNetwork")
    {
    IP4Address = IPA.ToString();
    break;
    }
    }
    return IP4Address;
    }

    private string checkoperator(string prefix, ref int opid)
    {
    string insert = string.Empty;
    string opname = string.Empty;
    string q = string.Empty;
    string q1 = string.Empty;
    int subnum = 5;
    opid = 0;

    q = string.Format("select * from country_op where prefix='{0}'", prefix.Trim());
    SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));
    DataTable dt = new DataTable();
    SqlCommand cmd = new SqlCommand(q, conn);
    SqlDataAdapter sqlDa1 = new SqlDataAdapter(cmd);
    sqlDa1.Fill(dt);


    if (dt != null && dt.Rows.Count > 0)
    {

    opname = dt.Rows[0]["op"].ToString();
    opid = Convert.ToInt32(dt.Rows[0]["id"]);

    }
    else
    {

    if (prefix.StartsWith("234") || prefix.StartsWith("26774") || prefix.StartsWith("26779") || prefix.StartsWith("26775") || prefix.StartsWith("9617") || prefix.StartsWith("23794")
    || prefix.StartsWith("225490") || prefix.StartsWith("225491") || prefix.StartsWith("225492") || prefix.StartsWith("225493") || prefix.StartsWith("2247"))
    {
    subnum = 6;
    }
    else if (prefix.StartsWith("26779"))
    {
    subnum = 7;
    }

    else if (prefix.StartsWith("2356") || prefix.StartsWith("2359") || prefix.StartsWith("965") || prefix.StartsWith("2535") || prefix.StartsWith("2536") || prefix.StartsWith("2537") || prefix.StartsWith("2538")
    || prefix.StartsWith("2917") || prefix.StartsWith("220") || prefix.StartsWith("2666") || prefix.StartsWith("2665") || prefix.StartsWith("231") || prefix.StartsWith("923"))
    {
    subnum = 4;
    }
    else
    {
    subnum = 5;
    }

    if (prefix.Length > subnum)
    {
    prefix = prefix.Substring(0, subnum);
    }

    q1 = string.Format("select * from country_op where prefix='{0}'", prefix.Trim());
    SqlConnection conn1 = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));
    DataTable dt1 = new DataTable();
    SqlCommand cmd1 = new SqlCommand(q1, conn1);
    SqlDataAdapter sqlDa2 = new SqlDataAdapter(cmd1);
    sqlDa2.Fill(dt1);


    if (dt1 != null && dt1.Rows.Count > 0)
    {

    opname = dt1.Rows[0]["op"].ToString();
    opid = Convert.ToInt32(dt1.Rows[0]["id"]);

    }
    else
    {
    opname = txtcountry.Text;
    opid = 0;
    }

    }

    return opname;
    }

    protected void txtdest_TextChanged(object sender, EventArgs e)
    {
    string q1 = string.Format("select * from bulkextentions where ext='{0}'", txtdest.Text.Trim());
    SqlConnection conn1 = new SqlConnection(ConfigurationManager.AppSettings.Get("DBBulk"));
    DataTable dt1 = new DataTable();
    SqlCommand cmd1 = new SqlCommand(q1, conn1);
    SqlDataAdapter sqlDa2 = new SqlDataAdapter(cmd1);
    sqlDa2.Fill(dt1);
    Label4.Text = "";

    if (dt1 != null && dt1.Rows.Count > 0)
    {

    Label4.Text = dt1.Rows[0]["typname"].ToString();
    TextBox1.Text = dt1.Rows[0]["limit"].ToString();
    }

    }
    }

  4. #4
    Membre confirmé
    Femme Profil pro
    Etudiante en Développement
    Inscrit en
    Avril 2012
    Messages
    106
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Etudiante en Développement
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2012
    Messages : 106
    Par défaut
    Merci d'utiliser les balises "code" pour une meilleure lisibilité
    Ca aurait été bien aussi de créer un nouveau sujet.

    Dans ce cas là, le message d'erreur est plutôt clair, as-tu fait un minimum de recherches ?
    On dirait que tu as juste tout copié et crier au secours dès que tu as vu une erreur.

    Bref, pour cette erreur il faut que tu fasses un clic droit sur le projet > Ajouter une référence puis aller chercher la dll qui contient Npgsql

    Il y a une documentation sur Npgsql ici, si cela peut t'aider :
    http://npgsql.projects.pgfoundry.org...serManual.html

  5. #5
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    +1 avec alucia

    le

    ne suffit pas. Il faut que tu rajoutes une référence vers le namespace Npgsql. Cela peut-être une référence .Net, un composant COM, un autre projet faisant partie de votre solution etc etc ...

    En gros c'est la fenêtre ci-jointe sous Visual Studio 2010
    Images attachées Images attachées  
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

  6. #6
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    merci de m'avoir répondu vite, malheureusement j'utilise visual studio 2005, en temps que débutant j'arrive pas à voir la fen^tre permettant d'ajouter les références
    Citation Envoyé par infosam76 Voir le message
    +1 avec alucia

    le

    ne suffit pas. Il faut que tu rajoutes une référence vers le namespace Npgsql. Cela peut-être une référence .Net, un composant COM, un autre projet faisant partie de votre solution etc etc ...

    En gros c'est la fenêtre ci-jointe sous Visual Studio 2010

  7. #7
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    merci de m'avoir répondu vite, malheureusement j'utilise visual studio 2005, en temps que débutant j'arrive pas à voir la fen^tre permettant d'ajouter les références

  8. #8
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    Je n'ai hélas plus de Visual Studio de 2005.

    Plusieurs pistes :

    - Voir si vous avez un menu "Projet" avec "Ajouter une référence" ou un truc du genre
    - Click droit sur votre Projet dans l'arborescence pour voir s'il n'est pas possible de le faire par la fenêtre des propriétés
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

  9. #9
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    Citation Envoyé par infosam76 Voir le message
    Je n'ai hélas plus de Visual Studio de 2005.

    Plusieurs pistes :

    - Voir si vous avez un menu "Projet" avec "Ajouter une référence" ou un truc du genre
    - Click droit sur votre Projet dans l'arborescence pour voir s'il n'est pas possible de le faire par la fenêtre des propriétés
    désolé mais on m'a donné une application waeb ne contenant pas le nom du projet dans ce cas est ce que je dois changer Npgsql.dll qui est dans le répertioire Bin?

  10. #10
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    Non justement quand tu passes par la fenêtre d'ajout d'une référence comme expliquer hier, tu as un onglet parcourir (sous visual studio 2010 en tout cas) qui te permet d'aller sélectionner la dll sur le disque.

    Donc je pense que dans ton cas tu dois sélectionner cette dll dans le répertoire bin
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

  11. #11
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    daccord, mais comme je viens de vous dire, on m'a juste laisser une application web que je voudrai amélioré, y a pas le nom du projet , il n' y a que des fichiers et des repertoires mais que je lance l'application voila mon erreur
    Server Error in '/' Application.

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0246: The type or namespace name 'Npgsql' could not be found (are you missing a using directive or an assembly reference?)

    Source Error:


    Line 13: using System.Text;
    Line 14: using System.Net;
    Line 15: using Npgsql;
    Line 16:
    Line 17: public partial class testschedule : System.Web.UI.Page

    Source File: c:\inetpub\wwwroot\marocautosend4\testschedule.aspx.cs Line: 15
    Images attachées Images attachées  

  12. #12
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    D'accord, je ne connais pas bien les applications Web.

    Mais comment ce fait la compilation alors ? Soit via un programme , ou un fichier .batch. Il faudrait voir dans les fichiers dont vous disposez où se font la déclaration des références car si using System.Net ne pose pas de problème et qu'elle fait partie du FrameWork, quelque part il y a quand même une référence vers ce namespace.
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

  13. #13
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    Daccord mais quand je mets un namespace après le using npgsql il me signale encore une erreure

  14. #14
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    Ce n'est pas dans le code que le namespace doit être spécifié. Il faut que les dlls contenant tous les namespace renseigné par les using soient référencés par votre projet pour que le compilateur sache où les trouver.

    Si joint une capture d'écran provenant de Visual studio pour vous montrez le concept
    Images attachées Images attachées  
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

  15. #15
    Membre à l'essai
    Homme Profil pro
    informatique
    Inscrit en
    Juin 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2012
    Messages : 7
    Par défaut
    Citation Envoyé par infosam76 Voir le message
    Ce n'est pas dans le code que le namespace doit être spécifié. Il faut que les dlls contenant tous les namespace renseigné par les using soient référencés par votre projet pour que le compilateur sache où les trouver.

    Si joint une capture d'écran provenant de Visual studio pour vous montrez le concept
    Est ce que je peux créer une nouvelle application ou je vais mettre les fichiers dont je dispose car comme je l'ai dit ci dessus on ne m'a pas laisser un projet, j'ai seulement un dossier de l'application hébergée sur le serveur IIS. Maintenant comment pourrais je faire pour résoudre mon probleme?

  16. #16
    Membre Expert


    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2006
    Messages
    970
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 970
    Par défaut
    C'est un fait qu'avec seulement les fichiers sources, je comprend même pas que vous arriviez à compiler. Mais faudrait voir avec quelqu'un qui a plus l'habitude avec les applications Web.

    Maintenant tenter de remettre le tout dans un projet est une bonne idée.
    Articles sur les technologies .NET

    Une réponse vous a aidé ? utilisez le bouton

    Votre problème est résolu ? utilisez le bouton

Discussions similaires

  1. Réponses: 5
    Dernier message: 28/09/2007, 10h38
  2. Réponses: 2
    Dernier message: 09/09/2007, 14h25
  3. Réponses: 8
    Dernier message: 04/06/2007, 16h20
  4. Réponses: 24
    Dernier message: 01/06/2007, 09h26
  5. Réponses: 8
    Dernier message: 11/07/2006, 17h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo