Click here to Skip to main content
15,903,175 members
Home / Discussions / C#
   

C#

 
GeneralRe: code colourizing Pin
Zhendalf27-Aug-07 11:17
Zhendalf27-Aug-07 11:17 
Questionhelp with a small problem Pin
swatgodjr26-Aug-07 11:18
swatgodjr26-Aug-07 11:18 
AnswerRe: help with a small problem Pin
Christian Graus26-Aug-07 11:25
protectorChristian Graus26-Aug-07 11:25 
AnswerRe: help with a small problem Pin
Vikram A Punathambekar26-Aug-07 18:40
Vikram A Punathambekar26-Aug-07 18:40 
QuestionBig Endian float conversion Pin
piote26-Aug-07 10:49
piote26-Aug-07 10:49 
AnswerRe: Big Endian float conversion Pin
Luc Pattyn26-Aug-07 13:51
sitebuilderLuc Pattyn26-Aug-07 13:51 
GeneralRe: Big Endian float conversion Pin
piote28-Aug-07 1:20
piote28-Aug-07 1:20 
QuestionDatabase Login Pin
Bonsta26-Aug-07 7:48
Bonsta26-Aug-07 7:48 
Hi got this code that is a potential solution to my Database login problem.It was originally in VB but I ran a converter on it. Now I have a OleDbDataReader method called Item(String) that was there when the code was in VB but now does not exist on the OleDbDataReader class in C#(dont know if that possible). Here is the full code. I need help to find the equivalent of this Item method in C#. The code connects to a access database and compares a textbox password entry to one in the database under the same user name given on another textbox...


private void btnLogin_Click(object sender, System.EventArgs e)
{
//The connection string is used to describe the type of database, the security information and the location to the database.
string ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=\"\";User ID=Admin;Data Source=\"databasename.mdb\";";
//Create a new connection object and assign the ConString Connection String above
OleDbConnection DBCon = new OleDbConnection(ConString);
// g_login is a global variable defined in a Module that captures the login name and passes it from form to form. To create this, just create a Module, say Module1.vb and in it put "Public g_login as String" {g meaning global and login to represent the global login}
GlobalVariables.g_login = this.textBox1.Text;

string strPassword = this.textBox2.Text;

if (GlobalVariables.g_login == "" || strPassword == "")
{
MessageBox.Show("You are missing information. Please make sure that both the username and password fields are filled out.", "Missing Info");
this.textBox1.Focus();
return;
}
// The database has two fields in the Users table. A UserID field, which is the primary key and declared as a text. The other field is Password, which is a text as well.
string strsql = "SELECT [UserID], [Password] FROM Users WHERE [UserID]='" + GlobalVariables.g_login + "' ";

OleDbCommand cm = new OleDbCommand(strsql, DBCon);
OleDbDataReader dr;
bool valid = false;
bool HasRows = false;
try {
DBCon.Open();
dr = cm.ExecuteReader();
if (dr.HasRows) {
while (dr.Read()) {
if (strPassword == dr.Item("Password")) {
valid = true;
}
}
HasRows = true;
}
dr.Close();
}
catch (OleDbException exO) {
MessageBox.Show(exO.Message);
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
finally {
if (DBCon.State == ConnectionState.Open) {
DBCon.Close();
}
cm = null;
dr = null;
DBCon.Dispose();
GC.Collect();
}
iCount = iCount + 1;
if (valid == true) {
Form n = new Form4();
n.Show();
this.Hide();
}
else if (iCount == 3) {
MessageBox.Show("Contact Developers!", "Invalid Info");
this.Close();
}
else if (HasRows == false) {
MessageBox.Show("Invalid user name, try again!", "Invalid Info");
this.textBox1.Focus();
this.textBox1.Text = "";
this.textBox2.Text = "";
}
else {
MessageBox.Show("Invalid password, try again!", "Invalid Info");
this.textBox2.Focus();
this.textBox2.Text = "";
}

}

Thanks in Advance.

Is this chair taken

AnswerRe: Database Login Pin
Nissim Salomon26-Aug-07 10:08
Nissim Salomon26-Aug-07 10:08 
QuestionHow do I re-create feature/control like Data Tips in Visual Studio .NET 2005 Pin
abbyjeet26-Aug-07 7:13
abbyjeet26-Aug-07 7:13 
QuestionGenetic Algorithm Pin
starist26-Aug-07 5:05
starist26-Aug-07 5:05 
AnswerRe: Genetic Algorithm Pin
Curtis Schlak.26-Aug-07 9:42
Curtis Schlak.26-Aug-07 9:42 
QuestionSystem.IO.Path Understanding [modified] Pin
adnanrafiq26-Aug-07 4:30
adnanrafiq26-Aug-07 4:30 
AnswerRe: System.IO.Path Understanding Pin
Mark Churchill26-Aug-07 4:48
Mark Churchill26-Aug-07 4:48 
GeneralRe: System.IO.Path Understanding Pin
adnanrafiq26-Aug-07 5:22
adnanrafiq26-Aug-07 5:22 
GeneralRe: System.IO.Path Understanding Pin
Mark Churchill26-Aug-07 19:41
Mark Churchill26-Aug-07 19:41 
GeneralRe: System.IO.Path Understanding Pin
adnanrafiq27-Aug-07 19:47
adnanrafiq27-Aug-07 19:47 
Questiondebugging a windows service... how? Pin
swjam26-Aug-07 3:14
swjam26-Aug-07 3:14 
AnswerRe: debugging a windows service... how? Pin
PIEBALDconsult26-Aug-07 4:21
mvePIEBALDconsult26-Aug-07 4:21 
GeneralRe: debugging a windows service... how? Pin
swjam26-Aug-07 4:47
swjam26-Aug-07 4:47 
GeneralRe: debugging a windows service... how? Pin
PIEBALDconsult26-Aug-07 5:20
mvePIEBALDconsult26-Aug-07 5:20 
GeneralRe: debugging a windows service... how? Pin
Mark Churchill26-Aug-07 17:56
Mark Churchill26-Aug-07 17:56 
Questionmy form get lost focus in MultiThread mod. Pin
hdv21226-Aug-07 2:35
hdv21226-Aug-07 2:35 
QuestionSELECT COL1,COL2,SUM(COL1,COL2) AS COL3 FROM TEST; Pin
Muammar©26-Aug-07 1:15
Muammar©26-Aug-07 1:15 
AnswerRe: SELECT COL1,COL2,SUM(COL1,COL2) AS COL3 FROM TEST; Pin
Christian Graus26-Aug-07 1:28
protectorChristian Graus26-Aug-07 1:28 

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.