Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. help

help

Scheduled Pinned Locked Moved C#
csharppostgresqldatabaselinqgraphics
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14523525
    wrote on last edited by
    #1

    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: 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[

    M 1 Reply Last reply
    0
    • M Member_14523525

      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: 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[

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      run the debugger and inspect the string "insert" and see if you can run that directly using one of the postgresql clients. This will most likely identify the issue. Also read up on sql injection attacks as you are inviting someone to destroy your database.

      Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

      OriginalGriffO M 3 Replies Last reply
      0
      • M Mycroft Holmes

        run the debugger and inspect the string "insert" and see if you can run that directly using one of the postgresql clients. This will most likely identify the issue. Also read up on sql injection attacks as you are inviting someone to destroy your database.

        Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        The annoying thing is that he has already copy'n'pasted the code to avoid SQL Injection elsewhere without understanding what the heck he is doing or why...

        Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • M Mycroft Holmes

          run the debugger and inspect the string "insert" and see if you can run that directly using one of the postgresql clients. This will most likely identify the issue. Also read up on sql injection attacks as you are inviting someone to destroy your database.

          Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

          M Offline
          M Offline
          Member_14523525
          wrote on last edited by
          #4

          PLEASE i do not understand well what you are saying :sigh:

          OriginalGriffO 1 Reply Last reply
          0
          • M Mycroft Holmes

            run the debugger and inspect the string "insert" and see if you can run that directly using one of the postgresql clients. This will most likely identify the issue. Also read up on sql injection attacks as you are inviting someone to destroy your database.

            Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

            M Offline
            M Offline
            Member_14523525
            wrote on last edited by
            #5

            i doont no how to run the debugger

            OriginalGriffO C M 3 Replies Last reply
            0
            • M Member_14523525

              PLEASE i do not understand well what you are saying :sigh:

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Quote:

              read up on sql injection attacks as you are inviting someone to destroy your database.

              What that means is this: never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you concatenate strings, you cause problems because SQL receives commands like:

              SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'

              The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:

              SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'

              Which SQL sees as three separate commands:

              SELECT * FROM MyTable WHERE StreetAddress = 'x';

              A perfectly valid SELECT

              DROP TABLE MyTable;

              A perfectly valid "delete the table" command

              --'

              And everything else is a comment. So it does: selects any matching rows, deletes the table from the DB, and ignores anything else. So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?

              Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              1 Reply Last reply
              0
              • M Member_14523525

                i doont no how to run the debugger

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                Then learn! The debugger is the biggest, badest, best tool in your box: chances are you will spend more time using that than you will your editor - even when you get more experience - because as you advance, so your code becomes more complex, and testing and diagnosing problems also becomes more complicated. So find out how to use the debugger, and start finding your problems. Judging by the amount of HTML there is stuffed into your sample, you are using VS Code, so start reading here: Debugging in Visual Studio Code[^] If you aren't, then start here: Navigate code with the debugger - Visual Studio | Microsoft Docs[^]

                Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                1 Reply Last reply
                0
                • M Member_14523525

                  i doont no how to run the debugger

                  C Offline
                  C Offline
                  CHill60
                  wrote on last edited by
                  #8

                  Another article to help you to learn how to debug Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

                  1 Reply Last reply
                  0
                  • M Member_14523525

                    i doont no how to run the debugger

                    M Offline
                    M Offline
                    Mycroft Holmes
                    wrote on last edited by
                    #9

                    Ok so you do not know the basics of software development, you should get a beginners book and work through the examples as you read the book BEFORE you start trying to build.

                    Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups