Click here to Skip to main content
14,239,593 members
   

C#

 
GeneralRe: I have two questions concerning what Visual Studio adds when you make a GUI project Pin
Member 1297423510-Jul-19 3:33
memberMember 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
protectorOriginalGriff10-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
mveBillWoodruff10-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
memberGreg 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
memberGreg Gonzales8-Jul-19 17:09 
Questionhelp Pin
Member 145235257-Jul-19 13:40
memberMember 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:

<pre>using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Threading.Tasks;<br />
using System.Windows.Forms;<br />
using Npgsql;<br />
using NpgsqlTypes;<br />
using WindowsFormsApplication1.Beans;<br />
<br />
namespace WindowsFormsApplication1<br />
{<br />
    public partial class inscription : Form<br />
    {<br />
        public static Client client;<br />
        DateTime date;<br />
        string Conx = "Server=localhost;Port=5432;Database=postgres;User=postgres;pwd=yannick93";<br />
        NpgsqlCommand MyCmd = null;<br />
        NpgsqlConnection MyCnx = null;<br />
        public inscription()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void label1_Click(object sender, EventArgs e)<br />
        {<br />
<br />
        }<br />
<br />
        private void label4_Click(object sender, EventArgs e)<br />
        {<br />
<br />
        }<br />
<br />
        private void textBox1_TextChanged(object sender, EventArgs e)<br />
        {<br />
<br />
        }<br />
<br />
        private void b_annuler1_Click(object sender, EventArgs e)<br />
        {<br />
<br />
        }<br />
<br />
        private void b_confirm1_Click(object sender, EventArgs e)<br />
        {<br />
<br />
            String nom = esp_nom.Text;<br />
            String prenom = esp_prenom.Text;<br />
            String adr = esp_adr.Text;<br />
            String ville = esp_ville.Text;<br />
            String pass = esp_pass.Text;<br />
            String confirm = esp_conf.Text;<br />
            if (nom == "" || prenom == "" || adr == "" || ville == "" || pass == "" || confirm == "")<br />
            {<br />
                MessageBox.Show("veuiller entrer tous les parametres", "parametres manquants");<br />
            }<br />
            else<br />
            {<br />
                if (!pass.Equals(confirm))<br />
                {<br />
                    MessageBox.Show("veuillez bien saisir votre mot de pass", "erreur de confirmation");<br />
                }<br />
                else<br />
                {<br />
                    Connexion connect = new Connexion();<br />
                    try<br />
                    {<br />
                        // connect.con.Open();<br />
                        date = DateTime.Now;<br />
                        String dateh = date.ToShortTimeString();<br />
                        String datej = date.ToShortDateString();<br />
                        var tabh = dateh.Split(':');<br />
                        var tabj = datej.Split('/');<br />
                        String h = tabh[0];<br />
                        String m = tabh[1];<br />
                        String j = tabj[0];<br />
                        String mois = tabj[1];<br />
                        String an = tabj[2];<br />
                        String dnom = nom.Substring(0, 1);<br />
                        String id = "dif-" + dnom + h + m + j + mois + an;<br />
<br />
<br />
                        client = new Client(id, nom, prenom, adr, ville, pass);<br />
<br />
<br />
                        string insert = "INSERT INTO client(id,nom,prenom,adr,ville,pass) values('" + client.id + "','" + client.nom + "','" + client.prenom + "','" + client.adr + "','" + client.ville + "','" + client.pass + "')";<br />
                        MessageBox.Show("erreur d'accessibilite 2", "error2");<br />
                        NpgsqlCommand MyCmd = connect.con.CreateCommand();<br />
                        MyCmd.CommandText = insert;<br />
                        MessageBox.Show("erreur d'accessibilite3", "error3");<br />
                        MyCmd.ExecuteNonQuery();<br />
                        MessageBox.Show("erreur d'accessibilite4", "error4");<br />
                        connect.con.Close();<br />
                        MessageBox.Show(dateh, datej);<br />
                    }<br />
                    catch (Exception)<br />
                    {<br />
                        MessageBox.Show("erreur d'accessibilite", "error");<br />
                    }<br />
                }<br />
            }<br />
        }<br />
<br />
        public void InsertPersons(string nom, string prenom, string tel, string adresse)<br />
        {<br />
            MyCnx = new NpgsqlConnection(Conx);<br />
            string insert = "INSERT INTO \"client\"(id,nom,prenom,adr,ville,pass) values(:id,:nom,:prenom,:adr,:ville,:pass)";<br />
            //La valeur DEFAULT parce que la propriété id est auto incrémenté<br />
            MyCnx.Open();<br />
            MyCmd = new NpgsqlCommand(insert, MyCnx);<br />
<br />
            //Définition  et ajout des paramètres <br />
<br />
            MyCmd.Parameters.Add(new NpgsqlParameter("id", NpgsqlDbType.Varchar)).Value = client.id;<br />
            MyCmd.Parameters.Add(new NpgsqlParameter("nom", NpgsqlDbType.Varchar)).Value = nom;<br />
            MyCmd.Parameters.Add(new NpgsqlParameter("nom", NpgsqlDbType.Varchar)).Value = nom;<br />
            MyCmd.Parameters.Add(new NpgsqlParameter("prenom", NpgsqlDbType.Varchar)).Value = prenom;<br />
            MyCmd.Parameters.Add(new NpgsqlParameter("tel", NpgsqlDbType.Varchar)).Value = tel;<br />
            MyCmd.Parameters.Add(new NpgsqlParameter("adresse", NpgsqlDbType.Varchar)).Value = adresse;<br />
<br />
            MyCmd.ExecuteNonQuery(); //Exécution<br />
            MyCnx.Close();<br />
        }<br />
<br />
    }<br />
}<br />
</pre>


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
memberMycroft Holmes7-Jul-19 17:48 
GeneralRe: help Pin
OriginalGriff7-Jul-19 18:46
protectorOriginalGriff7-Jul-19 18:46 
GeneralRe: help Pin
Member 145235257-Jul-19 21:49
memberMember 145235257-Jul-19 21:49 
GeneralRe: help Pin
OriginalGriff7-Jul-19 22:09
protectorOriginalGriff7-Jul-19 22:09 
GeneralRe: help Pin
Member 145235257-Jul-19 21:50
memberMember 145235257-Jul-19 21:50 
GeneralRe: help Pin
OriginalGriff7-Jul-19 22:14
protectorOriginalGriff7-Jul-19 22:14 
GeneralRe: help Pin
CHill608-Jul-19 2:17
protectorCHill608-Jul-19 2:17 
GeneralRe: help Pin
Mycroft Holmes8-Jul-19 11:26
memberMycroft Holmes8-Jul-19 11:26 
QuestionZKTeco with C# Pin
Member 142231355-Jul-19 20:01
memberMember 142231355-Jul-19 20:01 
AnswerRe: ZKTeco with C# Pin
OriginalGriff5-Jul-19 20:18
protectorOriginalGriff5-Jul-19 20:18 
GeneralRe: ZKTeco with C# Pin
BillWoodruff6-Jul-19 20:53
mveBillWoodruff6-Jul-19 20:53 
AnswerRe: ZKTeco with C# Pin
BillWoodruff6-Jul-19 20:50
mveBillWoodruff6-Jul-19 20:50 
QuestionC# LINQ JOIN: Getting out of memory exception Pin
Mou_kol5-Jul-19 10:03
memberMou_kol5-Jul-19 10:03 
AnswerRe: C# LINQ JOIN: Getting out of memory exception Pin
Mycroft Holmes5-Jul-19 13:28
memberMycroft Holmes5-Jul-19 13:28 
GeneralRe: C# LINQ JOIN: Getting out of memory exception Pin
Mou_kol8-Jul-19 5:53
memberMou_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
mveEddy 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.