Click here to Skip to main content
16,004,969 members
Home / Discussions / Database
   

Database

 
GeneralRe: LEFT JOIN ??? Pin
Halawlaws27-Aug-07 5:56
Halawlaws27-Aug-07 5:56 
GeneralRe: LEFT JOIN ??? Pin
Michael Potter27-Aug-07 6:01
Michael Potter27-Aug-07 6:01 
GeneralRe: LEFT JOIN ??? Pin
Halawlaws27-Aug-07 20:05
Halawlaws27-Aug-07 20:05 
GeneralRe: LEFT JOIN ??? Pin
Michael Potter28-Aug-07 3:24
Michael Potter28-Aug-07 3:24 
Questionreference data from database to textboxes Pin
RaveRare26-Aug-07 22:29
RaveRare26-Aug-07 22:29 
AnswerRe: reference data from database to textboxes Pin
Colin Angus Mackay27-Aug-07 0:56
Colin Angus Mackay27-Aug-07 0:56 
QuestionOh No, How this happened???? Pin
RaveRare26-Aug-07 20:21
RaveRare26-Aug-07 20:21 
QuestionDatabase Login Pin
Bonsta26-Aug-07 8:47
Bonsta26-Aug-07 8:47 
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...Also if there are any changes that I need to make to connect to an SQL Database Server.


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.0assword=\"\";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
Marek Grzenkowicz26-Aug-07 21:43
Marek Grzenkowicz26-Aug-07 21:43 
QuestionWhy the Column from Type BigInt must have name [Size] in SQL 2000 to work well ?!! Pin
I Believe In GOD26-Aug-07 5:39
I Believe In GOD26-Aug-07 5:39 
AnswerRe: Why the Column from Type BigInt must have name [Size] in SQL 2000 to work well ?!! Pin
Michael Sync26-Aug-07 17:44
Michael Sync26-Aug-07 17:44 
QuestionPleaes help me with this query Pin
Meysam Mahfouzi26-Aug-07 4:22
Meysam Mahfouzi26-Aug-07 4:22 
AnswerRe: Pleaes help me with this query Pin
Colin Angus Mackay26-Aug-07 5:35
Colin Angus Mackay26-Aug-07 5:35 
GeneralRe: Pleaes help me with this query Pin
Meysam Mahfouzi26-Aug-07 11:32
Meysam Mahfouzi26-Aug-07 11:32 
GeneralRe: Pleaes help me with this query Pin
Colin Angus Mackay26-Aug-07 11:44
Colin Angus Mackay26-Aug-07 11:44 
GeneralRe: Pleaes help me with this query Pin
Meysam Mahfouzi28-Aug-07 3:25
Meysam Mahfouzi28-Aug-07 3:25 
AnswerRe: Pleaes help me with this query Pin
Michael Potter27-Aug-07 5:41
Michael Potter27-Aug-07 5:41 
GeneralRe: Pleaes help me with this query Pin
Meysam Mahfouzi28-Aug-07 3:08
Meysam Mahfouzi28-Aug-07 3:08 
GeneralRe: Pleaes help me with this query Pin
Colin Angus Mackay28-Aug-07 6:55
Colin Angus Mackay28-Aug-07 6:55 
GeneralRe: Pleaes help me with this query Pin
Meysam Mahfouzi28-Aug-07 21:38
Meysam Mahfouzi28-Aug-07 21:38 
QuestionProblem with cursor Pin
Developer61126-Aug-07 4:06
Developer61126-Aug-07 4:06 
AnswerRe: Problem with cursor [modified] Pin
John-ph26-Aug-07 20:10
John-ph26-Aug-07 20:10 
AnswerRe: Problem with cursor Pin
John-ph26-Aug-07 21:08
John-ph26-Aug-07 21:08 
Questionconnect to MYSQL database located on web Pin
Rupesh Kumar Swami25-Aug-07 23:19
Rupesh Kumar Swami25-Aug-07 23:19 
QuestionHow to drop builtin\administrators account from sql server Pin
Developer61125-Aug-07 22:39
Developer61125-Aug-07 22:39 

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.