Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
GeneralRe: c# login help Pin
cobalt-rose20-Dec-08 2:32
cobalt-rose20-Dec-08 2:32 
AnswerRe: c# login help Pin
Christian Graus20-Dec-08 10:14
protectorChristian Graus20-Dec-08 10:14 
AnswerRe: c# login help Pin
RobScripta20-Dec-08 16:01
professionalRobScripta20-Dec-08 16:01 
GeneralRe: c# login help Pin
cobalt-rose21-Dec-08 1:49
cobalt-rose21-Dec-08 1:49 
GeneralRe: c# login help Pin
RobScripta21-Dec-08 20:58
professionalRobScripta21-Dec-08 20:58 
GeneralRe: c# login help Pin
cobalt-rose22-Dec-08 13:19
cobalt-rose22-Dec-08 13:19 
GeneralRe: c# login help Pin
RobScripta22-Dec-08 23:49
professionalRobScripta22-Dec-08 23:49 
GeneralRe: c# login help Pin
cobalt-rose23-Dec-08 22:18
cobalt-rose23-Dec-08 22:18 
Thank you for the tip, i am learning something new about c# with every message that you send.

Back to the problem, i did stuble across another person that was trying to get the login working and he said he managed to do so in the end so i have borrowed his code and adapted it....

It seems to almost correct except for when i click on the login button it waits a while and then says "you have an error in your SQL Syntax check the ,manual that" is this to do with the connection string of the actual SQL query? I feel that if i can correct this then it should work as it is the only erro that comes up when run? As always your help will be greatly appreciated.
C~Rose

Link to borrowed code http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/764cdca8-8464-497e-ac15-daab9d748724/br mode="hold" />My Code Below:

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 MySql.Data.MySqlClient;

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

private void textBox2_TextChanged(object sender, EventArgs e)
{
}

private void button1_Click(object sender, EventArgs e)
{
string uname = textBox1.Text;
string pword = textBox2.Text;

string connectionString = "Data Source=localhost" + ";Database=_consultants" + ";User ID=root" + ";Password=password;";
MySqlConnection MySqlConn = new MySqlConnection(connectionString);
string strSQL = ("SELECT (*) FROM user WHERE username = ' " + textBox1.Text + " 'AND password=' " + textBox2.Text + " ' ");
MySqlCommand mysqlCommand = new MySqlCommand(strSQL, MySqlConn);

try
{
MySqlConn.Open();
MySqlDataReader mysqlReader = mysqlCommand.ExecuteReader();
while (mysqlReader.Read())
{
string strusername;
string strpassword;

strusername = (mysqlReader["username"].ToString());
strpassword = (mysqlReader["password"].ToString());

if (strusername == uname && pword == strpassword)
{
textBox3.Text = "INCORRECT USER/PASS!";
}

else
{
textBox3.Text = "YOU ARE LOGGED IN!";
}
}
MySqlConn.Close();
}

catch (Exception ex)
{
MessageBox.Show("Wrong Input Entered", "Window Information" + ex.Message.ToString(),
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

private void textBox3_TextChanged(object sender, EventArgs e)
{
}
}
}
GeneralRe: c# login help Pin
RobScripta23-Dec-08 22:58
professionalRobScripta23-Dec-08 22:58 
GeneralRe: c# login help Pin
cobalt-rose24-Dec-08 1:56
cobalt-rose24-Dec-08 1:56 
GeneralRe: c# login help Pin
RobScripta24-Dec-08 3:45
professionalRobScripta24-Dec-08 3:45 
GeneralRe: c# login help Pin
cobalt-rose24-Dec-08 13:05
cobalt-rose24-Dec-08 13:05 
GeneralRe: c# login help Pin
RobScripta24-Dec-08 20:50
professionalRobScripta24-Dec-08 20:50 
QuestionDowngrading ReaderWriterLockSlim UpgradeableReadLock to simple ReadLock Pin
HosamAly19-Dec-08 23:28
HosamAly19-Dec-08 23:28 
AnswerRe: Downgrading ReaderWriterLockSlim UpgradeableReadLock to simple ReadLock Pin
N a v a n e e t h20-Dec-08 0:57
N a v a n e e t h20-Dec-08 0:57 
GeneralRe: Downgrading ReaderWriterLockSlim UpgradeableReadLock to simple ReadLock Pin
HosamAly20-Dec-08 2:41
HosamAly20-Dec-08 2:41 
GeneralRe: Downgrading ReaderWriterLockSlim UpgradeableReadLock to simple ReadLock Pin
N a v a n e e t h20-Dec-08 7:32
N a v a n e e t h20-Dec-08 7:32 
Questionhow to write the values in textbox to xml format.. Pin
samsonx19-Dec-08 22:26
samsonx19-Dec-08 22:26 
AnswerRe: how to write the values in textbox to xml format.. Pin
Eddy Vluggen19-Dec-08 22:33
professionalEddy Vluggen19-Dec-08 22:33 
GeneralRe: how to write the values in textbox to xml format.. Pin
samsonx19-Dec-08 22:49
samsonx19-Dec-08 22:49 
GeneralRe: how to write the values in textbox to xml format.. Pin
Eddy Vluggen19-Dec-08 23:01
professionalEddy Vluggen19-Dec-08 23:01 
GeneralRe: how to write the values in textbox to xml format.. Pin
samsonx19-Dec-08 23:14
samsonx19-Dec-08 23:14 
GeneralRe: how to write the values in textbox to xml format.. Pin
samsonx19-Dec-08 23:29
samsonx19-Dec-08 23:29 
GeneralRe: how to write the values in textbox to xml format.. Pin
Christian Graus19-Dec-08 23:32
protectorChristian Graus19-Dec-08 23:32 
GeneralRe: how to write the values in textbox to xml format.. Pin
Christian Graus19-Dec-08 23:31
protectorChristian Graus19-Dec-08 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.