error connecting to databaseAccess denied for use 'root'@'localhost(using password:YES)

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Windows.Forms;
using DPUruNet;
using System.Drawing.Imaging;
using System.Drawing;

namespace UareUBiometrics
{
    class HelperFunctions
    {
        private static Fmd[] fmds;

        private static Fmd[] allDBFmds;
        public static Fmd[] GetAllFmds
        {
            get { return allDBFmds; }

        } 

        private static string[] allUserNames;
        public static string[] GetAllUserNames
        {
            get { return allUserNames; }
        }

        private static int[] allfingerIDs;
        public static int[] GetallfingerIDs
        {
            get { return allfingerIDs; }
        }

        public static MySqlDataReader ConnectDBnExecuteSelectScript(string Script)
        {
            string connectionString = "server=localhost;User Id=root;database=customerInfo;Password=";
            MySqlDataReader dataReader = null;
            MySqlConnection conn = new MySqlConnection(connectionString);
            try
            {
                conn.Open();
                MySqlCommand sqlCommand = new MySqlCommand(Script, conn);
                dataReader = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);

            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Error opening connection" + ex.Message);
            }

            return dataReader;
        }

Recommended Answers

All 2 Replies

at this below line your not passing the password
string connectionString = "server=localhost;User Id=root;database=customerInfo;Password=";

Pgmer - what if i dont have password ,what is the correct syntax because im also using that line of codes

string connectionString = "server=localhost;User Id=root;database=customerInfo;Password=";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.