Click here to Skip to main content
15,888,733 members
Home / Discussions / C#
   

C#

 
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 
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 
I'm sorry, I didn't look right.

I think there are no records that meet the criteria.
My books says to use a data reader for performance reasons, but I've found that a data reader can even take longer than a dataset, so I always use a data set (perhaps if I make a million records application the datareader comes into play again).

The advantage of the dataset is you can check it in debug mode.

I have a standard function:

public static DataTable dtAlgemeen(string sql, string NaamRetourTabel)
{
MySqlConnection ConnMySQL;
MySqlCommand cmdMySql = new MySqlCommand();

ConnMySQL = new MySqlConnection(ConnectString());
cmdMySql.Connection = ConnMySQL;
try
{
ConnMySQL.Open();
MySqlDataAdapter da = new MySqlDataAdapter();

da.SelectCommand = new MySqlCommand(sql, ConnMySQL);
MySqlCommandBuilder sqlbuilder = new MySqlCommandBuilder(da);

DataSet ds = new DataSet();


da.Fill(ds, NaamRetourTabel );
DataTable dt = ds.Tables[NaamRetourTabel];




return dt;
}

catch (Exception e)
{

System.Windows.Forms.Clipboard.SetText(sql);
System.Windows.Forms.MessageBox.Show("Foutmelding:" + e.Message + Convert.ToChar(13) + e.GetType().ToString() + Convert.ToChar(13) + "SQL is niet uitgevoerd, SQL text gekopieerd naar clipboard");

return null;
}
finally
{
ConnMySQL.Close();
}


}


then I code in my main routine

DataTable dtUsers = dtAlgemeen("Select * from users", "users");

If you put a break on the next line you can see the actual data extracted from the database by clicking on the magnifying glass that appears when you hold the mouse pointer over the dtUsers word.

If the data is satisfactory, you can adjust your code to select only the record with the necessary data

string sql = "Select * from users where username = '" + this.TextBox1.Text + "' And password = '" + this.TextBox2.Text + "'";
dtUsers = dtAlgemeen(sql, "users");
if (dtUsers.Rows.Count ==0)
{
MessageBox.Show("Username does not exist, or Password invalid");
}
else
{
MessageBox.Show("You are now logged in");
//do your other things
}

Use the debugger to check your code line by line to see if the expected result occurs!

Rob
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 
GeneralRe: how to write the values in textbox to xml format.. Pin
Eddy Vluggen20-Dec-08 1:57
professionalEddy Vluggen20-Dec-08 1:57 
QuestionClick Event Pin
hotthoughtguy19-Dec-08 22:19
hotthoughtguy19-Dec-08 22:19 
AnswerRe: Click Event Pin
Eddy Vluggen19-Dec-08 22:44
professionalEddy Vluggen19-Dec-08 22:44 
AnswerRe: Click Event Pin
Lev Danielyan19-Dec-08 22:46
Lev Danielyan19-Dec-08 22:46 
AnswerRe: Click Event Pin
Christian Graus19-Dec-08 23:34
protectorChristian Graus19-Dec-08 23:34 

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.