1 Replies - 309 Views - Last Post: 30 April 2014 - 08:14 PM Rate Topic: -----

#1 danbendlin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-April 14

Program wont accept database information using parameters

Posted 30 April 2014 - 07:03 PM

Hi, I am creating a WinForm registration application and my program accepts user input information and stores it but I am struggling to use my login function. I believe there is an error in the area of cmd.Parameters.AddWithValue section, I dont think addwithvalue is correct any suggestions? I get a fatal crash has occurred when I click Login



string constring = "datasource=127.0.0.1;port=3306;username=root;password=welcome";
                string Query = "SELECT * FROM 'userinfo'.'users' where 'username' = @userid and 'password' = @password)";
                MySqlConnection conDatabase = new MySqlConnection(constring);
                MySqlCommand cmd = new MySqlCommand(Query, conDatabase);
                cmd.Parameters.AddWithValue("@userid", this.userid_txt.Text);
                cmd.Parameters.AddWithValue("@passone", this.passone_txt.Text);

                try
                {
                    conDatabase.Open();
                    cmd.ExecuteReader();
                    MessageBox.Show("Welcome to iDSTEM!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }


Thank you in advance for any help.

Fixed the crash error, simple typo but now I am getting SQL Syntax errors which I orginaly believed I fixed.

Self fixed, thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Program wont accept database information using parameters

#2 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Program wont accept database information using parameters

Posted 30 April 2014 - 08:14 PM

Don't put tic marks (') around column names.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1