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. How to print a recording

How to print a recording

Scheduled Pinned Locked Moved C#
databasesqlitetutoriallounge
20 Posts 2 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.
  • A Offline
    A Offline
    ago2486
    wrote on last edited by
    #1

    Google translate:

    Hello, I practice on a program that gives me numbers and random letters. I am connected to a database SQLite which works perfectly but my current concern is that I can not print. In the data source I do not see Data Sqlite for me connected, the tutorials that I look at are those who program under vb2013, 2015 ... me I am on vb2008. I would like to know how to make the data sqlite appear in my data source. Cordially..

    Original:

    Bonjour, Je m'exerce sur un programme qui me donne des chiffres et lettres aléatoire. Je suis connecté à une base de donnée SQLite qui fonctionne parfaitement mais mon soucis actuel c'est que je n'arrive pas à imprimer. Dans la source de donnée je ne voit de Data Sqlite pour me connecté, les tutos que je regarde concerne ceux qui programme sous vb2013, 2015... moi je suis sur vb2008. J'aimerais savoir comment faire apparaître le data sqlite dans ma source de donnée. Cordialement..

    OriginalGriffO 1 Reply Last reply
    0
    • A ago2486

      Google translate:

      Hello, I practice on a program that gives me numbers and random letters. I am connected to a database SQLite which works perfectly but my current concern is that I can not print. In the data source I do not see Data Sqlite for me connected, the tutorials that I look at are those who program under vb2013, 2015 ... me I am on vb2008. I would like to know how to make the data sqlite appear in my data source. Cordially..

      Original:

      Bonjour, Je m'exerce sur un programme qui me donne des chiffres et lettres aléatoire. Je suis connecté à une base de donnée SQLite qui fonctionne parfaitement mais mon soucis actuel c'est que je n'arrive pas à imprimer. Dans la source de donnée je ne voit de Data Sqlite pour me connecté, les tutos que je regarde concerne ceux qui programme sous vb2013, 2015... moi je suis sur vb2008. J'aimerais savoir comment faire apparaître le data sqlite dans ma source de donnée. Cordialement..

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

      This is an English language site, and we only accept questions and answers in that language: please use Google Translate in future to assist. I have added the translation to your question. Ceci est un site en Anglais, et nous acceptons seulement les questions et réponses dans cette langue: s'il vous plaît utiliser Google Translate à l'avenir pour vous aider. J'ai ajouté la traduction à votre question.

      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

      A 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        This is an English language site, and we only accept questions and answers in that language: please use Google Translate in future to assist. I have added the translation to your question. Ceci est un site en Anglais, et nous acceptons seulement les questions et réponses dans cette langue: s'il vous plaît utiliser Google Translate à l'avenir pour vous aider. J'ai ajouté la traduction à votre question.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

        A Offline
        A Offline
        ago2486
        wrote on last edited by
        #3

        Please excuse me for this error ...

        OriginalGriffO 1 Reply Last reply
        0
        • A ago2486

          Please excuse me for this error ...

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

          No problem! But I'm not sure I understand your question: it doesn't seem to have anything to do with printing? Can you share any code which demonstrates the problem, and explain what it does that you didn't expect, or doesn't do that you did? Sample data may also help as we don't have access to your screen, HDD, or database!

          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

          A 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            No problem! But I'm not sure I understand your question: it doesn't seem to have anything to do with printing? Can you share any code which demonstrates the problem, and explain what it does that you didn't expect, or doesn't do that you did? Sample data may also help as we don't have access to your screen, HDD, or database!

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

            A Offline
            A Offline
            ago2486
            wrote on last edited by
            #5

            excuse me how do you send a screenshot? ...
            I use the reaportView tool and you have to connect it to your database. I made a screenshot that I would like to introduce it to you

            OriginalGriffO 1 Reply Last reply
            0
            • A ago2486

              excuse me how do you send a screenshot? ...
              I use the reaportView tool and you have to connect it to your database. I made a screenshot that I would like to introduce it to you

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

              You can't post screenshots directly here - we have too many idiots who would post inappropriate material for that at present. You can post then to dropbox and post a link - but generally a good explanation with sample data works better (we can't copy'n'paste from an image into a DB or Visual Studio for testing).

              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

              A 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                You can't post screenshots directly here - we have too many idiots who would post inappropriate material for that at present. You can post then to dropbox and post a link - but generally a good explanation with sample data works better (we can't copy'n'paste from an image into a DB or Visual Studio for testing).

                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                A Offline
                A Offline
                ago2486
                wrote on last edited by
                #7

                There is something that escapes me ...
                This is the code for the form1
                (using System;
                using System.Collections.Generic;
                using System.ComponentModel;
                using System.Data;
                using System.Drawing;
                using System.Linq;
                using System.Text;
                using System.Windows.Forms;
                using System.Data.OleDb;
                using System.Data.SQLite;

                namespace Acode
                {
                    public partial class Form1: Form
                    {
                        public Form1 ()
                        {
                            InitializeComponent ();
                           
                        }
                        private SQLiteConnection sql_con;
                private SQLiteCommand sql_cmd;
                        private SQLiteDataAdapter DB;
                private DataSet DS = new DataSet ();
                private DataTable DT = new DataTable ();

                private void setConnection ()
                {
                sql_con = new SQLiteConnection (@ "Data Source = DBcode.db; Version = 3; New =; Compress = True;");
                }

                private void LoadData ()
                        {
                            SetConnection ();
                            sql_con.Open ();
                            sql_cmd = sql_con.CreateCommand ();
                            string CommandText = "select * from InfoCode";
                            DB = new SQLiteDataAdapter (CommandText, sql_con);
                            DS.Reset ();
                            DB.Fill (DS);
                            DT = DS.Tables [0];
                            dataGridView1.DataSource = DT;
                            sql_con.Close ();
                        }

                private void Form1_Load (object sender, EventArgs e)
                        {
                            LoadData ();

                }

                private void ExecuteQuery (String txtQuery)
                {
                        SetConnection ();
                sql_con.Open ();
                sql_cmd = sql_con.CreateCommand ();
                sql_cmd.CommandText = txtQuery;
                sql_cmd.ExecuteNonQuery ();
                sql_con.Close ();
                }

                public static string randomstring (int length)
                        {
                            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWYZ0123456789";
                            Random random = new Random ();
                            return new string (Enumerable.Repeat (floats, length) .Select (s => s [random.Next (s.Length)]). ToArray ());
                        }
                        private void btnGenerer_Click (object sender, EventArgs e)
                        {
                           
                            lblDisplay.Text = randomstring (4);
                            txtAfficPrice.Text = "100";
                        }

                private void button1_Click (object sender, EventArgs e)
                        {
                            lblDisplay.Text = randomstring (5);
                            txtAffichPrice.Text = "300";
                        }

                private void button2_Click (object sender, EventArgs e)
                        {
                            lblDisplay.Text = randomstring (6);
                            txtAffichPrice.Text = "500";
                        }

                private void btnRegister_Click (object sender, E

                OriginalGriffO 1 Reply Last reply
                0
                • A ago2486

                  There is something that escapes me ...
                  This is the code for the form1
                  (using System;
                  using System.Collections.Generic;
                  using System.ComponentModel;
                  using System.Data;
                  using System.Drawing;
                  using System.Linq;
                  using System.Text;
                  using System.Windows.Forms;
                  using System.Data.OleDb;
                  using System.Data.SQLite;

                  namespace Acode
                  {
                      public partial class Form1: Form
                      {
                          public Form1 ()
                          {
                              InitializeComponent ();
                             
                          }
                          private SQLiteConnection sql_con;
                  private SQLiteCommand sql_cmd;
                          private SQLiteDataAdapter DB;
                  private DataSet DS = new DataSet ();
                  private DataTable DT = new DataTable ();

                  private void setConnection ()
                  {
                  sql_con = new SQLiteConnection (@ "Data Source = DBcode.db; Version = 3; New =; Compress = True;");
                  }

                  private void LoadData ()
                          {
                              SetConnection ();
                              sql_con.Open ();
                              sql_cmd = sql_con.CreateCommand ();
                              string CommandText = "select * from InfoCode";
                              DB = new SQLiteDataAdapter (CommandText, sql_con);
                              DS.Reset ();
                              DB.Fill (DS);
                              DT = DS.Tables [0];
                              dataGridView1.DataSource = DT;
                              sql_con.Close ();
                          }

                  private void Form1_Load (object sender, EventArgs e)
                          {
                              LoadData ();

                  }

                  private void ExecuteQuery (String txtQuery)
                  {
                          SetConnection ();
                  sql_con.Open ();
                  sql_cmd = sql_con.CreateCommand ();
                  sql_cmd.CommandText = txtQuery;
                  sql_cmd.ExecuteNonQuery ();
                  sql_con.Close ();
                  }

                  public static string randomstring (int length)
                          {
                              const string chars = "ABCDEFGHIJKLMNOPQRSTUVWYZ0123456789";
                              Random random = new Random ();
                              return new string (Enumerable.Repeat (floats, length) .Select (s => s [random.Next (s.Length)]). ToArray ());
                          }
                          private void btnGenerer_Click (object sender, EventArgs e)
                          {
                             
                              lblDisplay.Text = randomstring (4);
                              txtAfficPrice.Text = "100";
                          }

                  private void button1_Click (object sender, EventArgs e)
                          {
                              lblDisplay.Text = randomstring (5);
                              txtAffichPrice.Text = "300";
                          }

                  private void button2_Click (object sender, EventArgs e)
                          {
                              lblDisplay.Text = randomstring (6);
                              txtAffichPrice.Text = "500";
                          }

                  private void btnRegister_Click (object sender, E

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

                  For starters, never do this:

                  string txtQuery = "insert into InfoCode (Code, DateCode, PriceCode) values ​​('" + lblDisplay.Text + "', '" + dateTimePicker1.Text + "', '" + txtAfficePrice.Text + "')";

                  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. Use Parametrized 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? That won't solve your problem, but it's a major risk that you need to address immediately. For the problem you have found, start with the debugger. Put a breakpoint on the line

                  dataGridView1.DataSource = DT;

                  and run your app. When it hits the breakpoint, have a close look at DT and see exactly what has been returned. How many columns? How many rows? What is in the actual cells? As an aside, you need to look at your naming conventions:

                  private void ExecuteQuery (String txtQuery)
                  {
                  SetConnection ();
                  sql_con.Open ();
                  sql_cmd = sql_con.CreateCommand ();
                  sql_cmd.CommandText = txtQuery;
                  sql_cmd.ExecuteNonQuery ();

                  In any code review, a method called ExecuteQuery which calls ExecuteNonQuery would be at target for abusive language! :laugh:

                  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

                  A 1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    For starters, never do this:

                    string txtQuery = "insert into InfoCode (Code, DateCode, PriceCode) values ​​('" + lblDisplay.Text + "', '" + dateTimePicker1.Text + "', '" + txtAfficePrice.Text + "')";

                    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. Use Parametrized 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? That won't solve your problem, but it's a major risk that you need to address immediately. For the problem you have found, start with the debugger. Put a breakpoint on the line

                    dataGridView1.DataSource = DT;

                    and run your app. When it hits the breakpoint, have a close look at DT and see exactly what has been returned. How many columns? How many rows? What is in the actual cells? As an aside, you need to look at your naming conventions:

                    private void ExecuteQuery (String txtQuery)
                    {
                    SetConnection ();
                    sql_con.Open ();
                    sql_cmd = sql_con.CreateCommand ();
                    sql_cmd.CommandText = txtQuery;
                    sql_cmd.ExecuteNonQuery ();

                    In any code review, a method called ExecuteQuery which calls ExecuteNonQuery would be at target for abusive language! :laugh:

                    Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                    A Offline
                    A Offline
                    ago2486
                    wrote on last edited by
                    #9

                    Thank you for all these tips for me will be a pulse to my learning. it's in my research that I found but what do you recommend to me?
                    I correct this error before talking about printing or after?

                    OriginalGriffO 1 Reply Last reply
                    0
                    • A ago2486

                      Thank you for all these tips for me will be a pulse to my learning. it's in my research that I found but what do you recommend to me?
                      I correct this error before talking about printing or after?

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

                      I'd correct it first - if only because once you fix the other problem you probably won't "get around to it" otherwise! :laugh:

                      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

                      A 1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        I'd correct it first - if only because once you fix the other problem you probably won't "get around to it" otherwise! :laugh:

                        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                        A Offline
                        A Offline
                        ago2486
                        wrote on last edited by
                        #11

                        Frankly thank you for giving me your time. give me a few minutes just the time for me to redo my connection and I come back to you.

                        OriginalGriffO 1 Reply Last reply
                        0
                        • A ago2486

                          Frankly thank you for giving me your time. give me a few minutes just the time for me to redo my connection and I come back to you.

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

                          Not a problem!

                          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

                          A 1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            Not a problem!

                            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                            A Offline
                            A Offline
                            ago2486
                            wrote on last edited by
                            #13

                            using System;
                            using System.Collections.Generic;
                            using System.ComponentModel;
                            using System.Data;
                            using System.Drawing;
                            using System.Linq;
                            using System.Text;
                            using System.Windows.Forms;
                            using System.Data.OleDb;
                            using System.Data.SQLite;

                            namespace Acode
                            {
                            public partial class Form1 : Form
                            {
                            public Form1()
                            {
                            InitializeComponent();

                                }
                                private SQLiteConnection sql\_con;
                                private SQLiteCommand sql\_cmd;
                                private SQLiteDataAdapter DB;
                                private DataSet DS = new DataSet();
                                private DataTable DT = new DataTable();
                            
                                private void setConnection()
                                {
                                sql\_con = new SQLiteConnection(@"Data Source=DBcode.db; Version=3;New=;Compress=True;");
                                }
                            
                                private void LoadData()
                                {
                                    setConnection();
                                    sql\_con.Open();
                                    sql\_cmd = sql\_con.CreateCommand();
                                    sql\_cmd.CommandText = "select \* from InfoCode";
                                    DB = new SQLiteDataAdapter(sql\_cmd.CommandText, sql\_con);
                                    DS.Reset();
                                    DB.Fill(DS);
                                    DT = DS.Tables\[0\];
                                    dataGridView1.DataSource = DT;
                                    sql\_con.Close();
                                }
                            
                                private void Form1\_Load(object sender, EventArgs e)
                                {
                                    LoadData();
                            
                                }
                            
                                private void ExecuteQuery()
                                {
                                setConnection();
                                sql\_con.Open();
                                sql\_cmd = sql\_con.CreateCommand();
                                //sql\_cmd.CommandText = txtQuery;
                                //sql\_cmd.ExecuteNonQuery();
                                sql\_con.Close();
                                }
                            
                                public static string randomstring(int length)
                                {
                                    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWYZ0123456789";
                                    Random random = new Random();
                                    return new string(Enumerable.Repeat(chars, length).Select(s => s\[random.Next(s.Length)\]).ToArray());
                                }
                                private void btnGenerer\_Click(object sender, EventArgs e)
                                {
                                   
                                    lblAffichage.Text = randomstring(4);
                                    txtAffichPrix.Text = "100";
                                }
                            
                                private void button1\_Click(object sender, EventArgs e)
                                {
                                    lblAffichage.Text = randomstring(5);
                                    txtAffichPrix.Text = "300";
                                }
                            
                                private void button2\_Click(object sender, EventArgs e)
                                {
                                    lblAffichage.Text = randomstring(6);
                                    txtAffichPrix.Text = "500";
                                }
                            
                               
                                private void btnEnregistrer\_Click(object sender, EventArgs e)
                                {
                                    if (lblAffichage.
                            
                            OriginalGriffO 1 Reply Last reply
                            0
                            • A ago2486

                              using System;
                              using System.Collections.Generic;
                              using System.ComponentModel;
                              using System.Data;
                              using System.Drawing;
                              using System.Linq;
                              using System.Text;
                              using System.Windows.Forms;
                              using System.Data.OleDb;
                              using System.Data.SQLite;

                              namespace Acode
                              {
                              public partial class Form1 : Form
                              {
                              public Form1()
                              {
                              InitializeComponent();

                                  }
                                  private SQLiteConnection sql\_con;
                                  private SQLiteCommand sql\_cmd;
                                  private SQLiteDataAdapter DB;
                                  private DataSet DS = new DataSet();
                                  private DataTable DT = new DataTable();
                              
                                  private void setConnection()
                                  {
                                  sql\_con = new SQLiteConnection(@"Data Source=DBcode.db; Version=3;New=;Compress=True;");
                                  }
                              
                                  private void LoadData()
                                  {
                                      setConnection();
                                      sql\_con.Open();
                                      sql\_cmd = sql\_con.CreateCommand();
                                      sql\_cmd.CommandText = "select \* from InfoCode";
                                      DB = new SQLiteDataAdapter(sql\_cmd.CommandText, sql\_con);
                                      DS.Reset();
                                      DB.Fill(DS);
                                      DT = DS.Tables\[0\];
                                      dataGridView1.DataSource = DT;
                                      sql\_con.Close();
                                  }
                              
                                  private void Form1\_Load(object sender, EventArgs e)
                                  {
                                      LoadData();
                              
                                  }
                              
                                  private void ExecuteQuery()
                                  {
                                  setConnection();
                                  sql\_con.Open();
                                  sql\_cmd = sql\_con.CreateCommand();
                                  //sql\_cmd.CommandText = txtQuery;
                                  //sql\_cmd.ExecuteNonQuery();
                                  sql\_con.Close();
                                  }
                              
                                  public static string randomstring(int length)
                                  {
                                      const string chars = "ABCDEFGHIJKLMNOPQRSTUVWYZ0123456789";
                                      Random random = new Random();
                                      return new string(Enumerable.Repeat(chars, length).Select(s => s\[random.Next(s.Length)\]).ToArray());
                                  }
                                  private void btnGenerer\_Click(object sender, EventArgs e)
                                  {
                                     
                                      lblAffichage.Text = randomstring(4);
                                      txtAffichPrix.Text = "100";
                                  }
                              
                                  private void button1\_Click(object sender, EventArgs e)
                                  {
                                      lblAffichage.Text = randomstring(5);
                                      txtAffichPrix.Text = "300";
                                  }
                              
                                  private void button2\_Click(object sender, EventArgs e)
                                  {
                                      lblAffichage.Text = randomstring(6);
                                      txtAffichPrix.Text = "500";
                                  }
                              
                                 
                                  private void btnEnregistrer\_Click(object sender, EventArgs e)
                                  {
                                      if (lblAffichage.
                              
                              OriginalGriffO Offline
                              OriginalGriffO Offline
                              OriginalGriff
                              wrote on last edited by
                              #14

                              No, when I meant was "Don't concatenate strings" and "Parameterized queries" are teh important bit:

                              sql_cmd.CommandText = "insert into InfoCode (Code, DateCode, PrixCode) values('" + lblAffichage.Text + "' , '" + dateTimePicker1.Text + "' , '" + txtAffichPrix.Text + "')";

                              Is extremely dangerous, not the "wrong name" bit! :laugh:

                              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

                              A 1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                No, when I meant was "Don't concatenate strings" and "Parameterized queries" are teh important bit:

                                sql_cmd.CommandText = "insert into InfoCode (Code, DateCode, PrixCode) values('" + lblAffichage.Text + "' , '" + dateTimePicker1.Text + "' , '" + txtAffichPrix.Text + "')";

                                Is extremely dangerous, not the "wrong name" bit! :laugh:

                                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                A Offline
                                A Offline
                                ago2486
                                wrote on last edited by
                                #15

                                but what should I do? since you asked me to correct the error. can you tell me more so that I can understand

                                OriginalGriffO 1 Reply Last reply
                                0
                                • A ago2486

                                  but what should I do? since you asked me to correct the error. can you tell me more so that I can understand

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

                                  Have a google for Parameterized queries - there is a lot out there. But basically:

                                          using (SqlConnection con = new SqlConnection(strConnect))
                                              {
                                              con.Open();
                                              using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
                                                  {
                                                  cmd.Parameters.AddWithValue("@C1", myValueForColumn1);
                                                  cmd.Parameters.AddWithValue("@C2", myValueForColumn2);
                                                  cmd.ExecuteNonQuery();
                                                  }
                                              }
                                  

                                  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

                                  A 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    Have a google for Parameterized queries - there is a lot out there. But basically:

                                            using (SqlConnection con = new SqlConnection(strConnect))
                                                {
                                                con.Open();
                                                using (SqlCommand cmd = new SqlCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
                                                    {
                                                    cmd.Parameters.AddWithValue("@C1", myValueForColumn1);
                                                    cmd.Parameters.AddWithValue("@C2", myValueForColumn2);
                                                    cmd.ExecuteNonQuery();
                                                    }
                                                }
                                    

                                    Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                    A Offline
                                    A Offline
                                    ago2486
                                    wrote on last edited by
                                    #17

                                    i will do it aisin and come back to you, thanks for your help

                                    A 1 Reply Last reply
                                    0
                                    • A ago2486

                                      i will do it aisin and come back to you, thanks for your help

                                      A Offline
                                      A Offline
                                      ago2486
                                      wrote on last edited by
                                      #18

                                      private void btnAdd_Click(object sender, EventArgs e)
                                      {
                                      if (lblAffichage.Text == "")
                                      {
                                      MessageBox.Show("Merci de bien vouloir générer le code");
                                      }
                                      else
                                      {
                                      using (SQLiteConnection con = new SQLiteConnection(sql_con))
                                      {
                                      con.Open();
                                      using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO InfoCode (Code, DateCode, PrixCode) VALUES (@Code, @DateCode, @PrixCode)", con))
                                      {
                                      cmd.Parameters.AddWithValue("@Code", lblAffichage.Text);
                                      cmd.Parameters.AddWithValue("@DateCode", dateTimePicker1.Text);
                                      cmd.Parameters.AddWithValue("@PrixCode", txtAffichPrix.Text);
                                      cmd.ExecuteNonQuery();
                                      }
                                      LoadData();
                                      MessageBox.Show("Enregistrement effectué avec succès");
                                      lblAffichage.Text = "";
                                      groupBoxGenerer.Enabled = false;
                                      btnEnregistrer.Enabled = false;
                                      this.Refresh();
                                      }
                                      }
                                      }
                                      Thank you very much for your help ... it works

                                      A 1 Reply Last reply
                                      0
                                      • A ago2486

                                        private void btnAdd_Click(object sender, EventArgs e)
                                        {
                                        if (lblAffichage.Text == "")
                                        {
                                        MessageBox.Show("Merci de bien vouloir générer le code");
                                        }
                                        else
                                        {
                                        using (SQLiteConnection con = new SQLiteConnection(sql_con))
                                        {
                                        con.Open();
                                        using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO InfoCode (Code, DateCode, PrixCode) VALUES (@Code, @DateCode, @PrixCode)", con))
                                        {
                                        cmd.Parameters.AddWithValue("@Code", lblAffichage.Text);
                                        cmd.Parameters.AddWithValue("@DateCode", dateTimePicker1.Text);
                                        cmd.Parameters.AddWithValue("@PrixCode", txtAffichPrix.Text);
                                        cmd.ExecuteNonQuery();
                                        }
                                        LoadData();
                                        MessageBox.Show("Enregistrement effectué avec succès");
                                        lblAffichage.Text = "";
                                        groupBoxGenerer.Enabled = false;
                                        btnEnregistrer.Enabled = false;
                                        this.Refresh();
                                        }
                                        }
                                        }
                                        Thank you very much for your help ... it works

                                        A Offline
                                        A Offline
                                        ago2486
                                        wrote on last edited by
                                        #19

                                        Hello sir I was able to find a solution to print, I'm going through a DataSet: I connected the DataSet to my database

                                        :thumbsup:

                                        A 1 Reply Last reply
                                        0
                                        • A ago2486

                                          Hello sir I was able to find a solution to print, I'm going through a DataSet: I connected the DataSet to my database

                                          :thumbsup:

                                          A Offline
                                          A Offline
                                          ago2486
                                          wrote on last edited by
                                          #20

                                          here is the code: {
                                          setConnection();
                                          sql_con.Open();
                                          sql_cmd = sql_con.CreateCommand();
                                          string CommandText = "select * from InfoCode";
                                          DB = new SQLiteDataAdapter(CommandText, sql_con);
                                          DS.Reset();
                                          CrystalReportImprimCode x = new CrystalReportImprimCode();
                                          DBset dt = new DBset();
                                          DB.Fill(dt.InfoCode);
                                          x.SetDataSource((DataTable)dt.InfoCode);
                                          crystalReportViewer1.ReportSource = x;
                                          crystalReportViewer1.Refresh();
                                          sql_con.Close();
                                          }

                                          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