Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

facing Problem regarding Remote Connection to Database...

$
0
0

Hello Every one,

I am new in C# and i created a POS previously, now i want to improve it and database can be placed at any server and others can access the database through remoting, i need help in doing this, i have written some code but its not working well,

Here is my Code

try
            {

string connString = "datasource = localhost; port = 3306; username = root; password = ;";

                MySqlConnection conn = new MySqlConnection(connString);
                MySqlCommand command = conn.CreateCommand();

                command.CommandText = "SELECT * FROM shdeulling.login where Username ='shedulling'";
                try
                {
                    conn.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                string k=null;
                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    k = reader.GetString(1);
                }
                if (k.Equals(string2))
                {
                    t = true;
                    return t;
                }
                else
                {
                    t = false;
                    conn.Close();
                    return t;
                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return t;
        }



Viewing all articles
Browse latest Browse all 18858

Trending Articles