Click here to Skip to main content
15,898,732 members
Home / Discussions / C#
   

C#

 
GeneralRe: I have two questions concerning what Visual Studio adds when you make a GUI project Pin
Member 1297423510-Jul-19 3:33
Member 1297423510-Jul-19 3:33 
GeneralRe: I have two questions concerning what Visual Studio adds when you make a GUI project Pin
OriginalGriff10-Jul-19 4:34
mveOriginalGriff10-Jul-19 4:34 
GeneralRe: I have two questions concerning what Visual Studio adds when you make a GUI project Pin
BillWoodruff10-Jul-19 6:43
professionalBillWoodruff10-Jul-19 6:43 
AnswerRe: I have two questions concerning what Visual Studio adds when you make a GUI project Pin
Gerry Schmitz10-Jul-19 6:49
mveGerry Schmitz10-Jul-19 6:49 
QuestionTo me this error msg is very cryptic! I am using VS2017 with MS Excel 2007 Pin
Greg Gonzales8-Jul-19 11:43
Greg Gonzales8-Jul-19 11:43 
AnswerRe: To me this error msg is very cryptic! I am using VS2017 with MS Excel 2007 Pin
Dave Kreskowiak8-Jul-19 11:54
mveDave Kreskowiak8-Jul-19 11:54 
GeneralRe: To me this error msg is very cryptic! I am using VS2017 with MS Excel 2007 Pin
Greg Gonzales8-Jul-19 17:09
Greg Gonzales8-Jul-19 17:09 
Questionhelp Pin
Member 145235257-Jul-19 13:40
Member 145235257-Jul-19 13:40 
hello!!!! my C# code is not going on i have some difficulties to write on my database(postgresql with pgadmin4) this is my code please help me Sigh | :sigh:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Npgsql;
using NpgsqlTypes;
using WindowsFormsApplication1.Beans;

namespace WindowsFormsApplication1
{
    public partial class inscription : Form
    {
        public static Client client;
        DateTime date;
        string Conx = "Server=localhost;Port=5432;Database=postgres;User=postgres;pwd=yannick93";
        NpgsqlCommand MyCmd = null;
        NpgsqlConnection MyCnx = null;
        public inscription()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void b_annuler1_Click(object sender, EventArgs e)
        {

        }

        private void b_confirm1_Click(object sender, EventArgs e)
        {

            String nom = esp_nom.Text;
            String prenom = esp_prenom.Text;
            String adr = esp_adr.Text;
            String ville = esp_ville.Text;
            String pass = esp_pass.Text;
            String confirm = esp_conf.Text;
            if (nom == "" || prenom == "" || adr == "" || ville == "" || pass == "" || confirm == "")
            {
                MessageBox.Show("veuiller entrer tous les parametres", "parametres manquants");
            }
            else
            {
                if (!pass.Equals(confirm))
                {
                    MessageBox.Show("veuillez bien saisir votre mot de pass", "erreur de confirmation");
                }
                else
                {
                    Connexion connect = new Connexion();
                    try
                    {
                        // connect.con.Open();
                        date = DateTime.Now;
                        String dateh = date.ToShortTimeString();
                        String datej = date.ToShortDateString();
                        var tabh = dateh.Split(':');
                        var tabj = datej.Split('/');
                        String h = tabh[0];
                        String m = tabh[1];
                        String j = tabj[0];
                        String mois = tabj[1];
                        String an = tabj[2];
                        String dnom = nom.Substring(0, 1);
                        String id = "dif-" + dnom + h + m + j + mois + an;


                        client = new Client(id, nom, prenom, adr, ville, pass);


                        string insert = "INSERT INTO client(id,nom,prenom,adr,ville,pass) values('" + client.id + "','" + client.nom + "','" + client.prenom + "','" + client.adr + "','" + client.ville + "','" + client.pass + "')";
                        MessageBox.Show("erreur d'accessibilite 2", "error2");
                        NpgsqlCommand MyCmd = connect.con.CreateCommand();
                        MyCmd.CommandText = insert;
                        MessageBox.Show("erreur d'accessibilite3", "error3");
                        MyCmd.ExecuteNonQuery();
                        MessageBox.Show("erreur d'accessibilite4", "error4");
                        connect.con.Close();
                        MessageBox.Show(dateh, datej);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("erreur d'accessibilite", "error");
                    }
                }
            }
        }

        public void InsertPersons(string nom, string prenom, string tel, string adresse)
        {
            MyCnx = new NpgsqlConnection(Conx);
            string insert = "INSERT INTO \"client\"(id,nom,prenom,adr,ville,pass) values(:id,:nom,:prenom,:adr,:ville,:pass)";
            //La valeur DEFAULT parce que la propriété id est auto incrémenté
            MyCnx.Open();
            MyCmd = new NpgsqlCommand(insert, MyCnx);

            //Définition  et ajout des paramètres 

            MyCmd.Parameters.Add(new NpgsqlParameter("id", NpgsqlDbType.Varchar)).Value = client.id;
            MyCmd.Parameters.Add(new NpgsqlParameter("nom", NpgsqlDbType.Varchar)).Value = nom;
            MyCmd.Parameters.Add(new NpgsqlParameter("nom", NpgsqlDbType.Varchar)).Value = nom;
            MyCmd.Parameters.Add(new NpgsqlParameter("prenom", NpgsqlDbType.Varchar)).Value = prenom;
            MyCmd.Parameters.Add(new NpgsqlParameter("tel", NpgsqlDbType.Varchar)).Value = tel;
            MyCmd.Parameters.Add(new NpgsqlParameter("adresse", NpgsqlDbType.Varchar)).Value = adresse;

            MyCmd.ExecuteNonQuery(); //Exécution
            MyCnx.Close();
        }

    }
}


this my error
<pre>A first chance exception of type 'System.InvalidOperationException' occurred in Npgsql.dll
The thread 'vshost.RunParkingWindow' (0x338) has exited with code 0 (0x0).
The thread '<No Name>' (0x1658) has exited with code 0 (0x0).
The program '[7312] WindowsFormsApplication1.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[7312] WindowsFormsApplication1.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).

AnswerRe: help Pin
Mycroft Holmes7-Jul-19 17:48
professionalMycroft Holmes7-Jul-19 17:48 
GeneralRe: help Pin
OriginalGriff7-Jul-19 18:46
mveOriginalGriff7-Jul-19 18:46 
GeneralRe: help Pin
Member 145235257-Jul-19 21:49
Member 145235257-Jul-19 21:49 
GeneralRe: help Pin
OriginalGriff7-Jul-19 22:09
mveOriginalGriff7-Jul-19 22:09 
GeneralRe: help Pin
Member 145235257-Jul-19 21:50
Member 145235257-Jul-19 21:50 
GeneralRe: help Pin
OriginalGriff7-Jul-19 22:14
mveOriginalGriff7-Jul-19 22:14 
GeneralRe: help Pin
CHill608-Jul-19 2:17
mveCHill608-Jul-19 2:17 
GeneralRe: help Pin
Mycroft Holmes8-Jul-19 11:26
professionalMycroft Holmes8-Jul-19 11:26 
QuestionZKTeco with C# Pin
Member 142231355-Jul-19 20:01
Member 142231355-Jul-19 20:01 
AnswerRe: ZKTeco with C# Pin
OriginalGriff5-Jul-19 20:18
mveOriginalGriff5-Jul-19 20:18 
GeneralRe: ZKTeco with C# Pin
BillWoodruff6-Jul-19 20:53
professionalBillWoodruff6-Jul-19 20:53 
AnswerRe: ZKTeco with C# Pin
BillWoodruff6-Jul-19 20:50
professionalBillWoodruff6-Jul-19 20:50 
QuestionC# LINQ JOIN: Getting out of memory exception Pin
Mou_kol5-Jul-19 10:03
Mou_kol5-Jul-19 10:03 
AnswerRe: C# LINQ JOIN: Getting out of memory exception Pin
Mycroft Holmes5-Jul-19 13:28
professionalMycroft Holmes5-Jul-19 13:28 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Mou_kol8-Jul-19 5:53
Mou_kol8-Jul-19 5:53 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Dave Kreskowiak8-Jul-19 6:27
mveDave Kreskowiak8-Jul-19 6:27 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Eddy Vluggen8-Jul-19 8:22
professionalEddy Vluggen8-Jul-19 8:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.