Hello i just started up today with C#,
Im femilair with PHP so i can do some things i have google etc.
But now im stuck.. with this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
username.Text = "";
password.PasswordChar = '*';
string loginus = "";
string loginpas = "";
loginus = username.Text;
loginpas = password.Text;
if (loginus == false)
{
string MyConString = "SERVER=localhost;" +
"DATABASE=ot;" +
"UID=" + loginus + ";" +
"PASSWORD=" + loginpas + ";";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from players ORDER BY id";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string idPlayers = "";
idPlayers = Reader.GetString(0) + "\t" + Reader.GetString(1);
listBox1.Items.Add(idPlayers);
}
connection.Close();
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string loginus = "";
string loginpas = "";
loginus = username.Text;
loginpas = password.Text;
}
}
}
I made a form with a user/password fields and a logon button,
and a field that reads from DB. Everything did work, but now i want to make the user/password field active to work (to access the db) not sure how yet.. so if you guys can help me with that also it would be greate!
With this code im getting the error for the if statement i made ;)
(not sure how to fix it properly)
Im not sure if some one can help me out