hey
I have another problem and it *will* be the last....
when i try to compare values from the textboxes and the values from the database i get....nothing. Not sure if it has something todo with my SELECT statement.
============================================
using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Net.Sockets;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace FrmLogin
{
public class SqlConn
{
private MySqlConnection sqlconn;
private MySqlCommand sqlcmd;
private string connstr;
public SqlConn(string server, string userid, string password)
{
connstr = String.Format("server={0}; userid={1}; password={2}; database=USERS", server, userid, password);
}
public void Connect()
{
if (null != sqlconn)
{
sqlconn.Close();
}
try {
sqlconn = new MySqlConnection(connstr);
sqlconn.Open();
} catch (MySqlException sqlex) {
throw new Exception("Couldn't connect to server: " +sqlex.Message);
} catch (SocketException sex) {
sex = null;
throw new Exception("Check your connection to the database....");
}
}
public void Auth(TextBox Usrname, TextBox Password)
{
string syntax = "SELECT username FROM info WHERE username=@username";
MySqlDataReader daread = null;
sqlcmd = new MySqlCommand(syntax, sqlconn);
daread = sqlcmd.ExecuteReader();
/* MySqlParameter going;
going = sqlcmd.Parameters.Add("@username", MySqlDbType.VarChar);
going.Direction = ParameterDirection.Input;
going.Value = Usrname.Text; */
try
{
while (daread.Read())
{
if (going.Value == Usrname.Text)
{
Password.Text = "........";
} else {
Password.Text = "not right";
}
}
} catch(MySqlException ex) {
throw new Exception(ex.Message);
} finally {
if (daread != null) daread.Close();
}
}
}
}
=========================================
this was my last attempt. i can get the values normally through the sqlcmd.GetString(0) and that works but i cant compare even with mysqlparameters :/.
I have another problem and it *will* be the last....
when i try to compare values from the textboxes and the values from the database i get....nothing. Not sure if it has something todo with my SELECT statement.
============================================
using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Net.Sockets;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace FrmLogin
{
public class SqlConn
{
private MySqlConnection sqlconn;
private MySqlCommand sqlcmd;
private string connstr;
public SqlConn(string server, string userid, string password)
{
connstr = String.Format("server={0}; userid={1}; password={2}; database=USERS", server, userid, password);
}
public void Connect()
{
if (null != sqlconn)
{
sqlconn.Close();
}
try {
sqlconn = new MySqlConnection(connstr);
sqlconn.Open();
} catch (MySqlException sqlex) {
throw new Exception("Couldn't connect to server: " +sqlex.Message);
} catch (SocketException sex) {
sex = null;
throw new Exception("Check your connection to the database....");
}
}
public void Auth(TextBox Usrname, TextBox Password)
{
string syntax = "SELECT username FROM info WHERE username=@username";
MySqlDataReader daread = null;
sqlcmd = new MySqlCommand(syntax, sqlconn);
daread = sqlcmd.ExecuteReader();
/* MySqlParameter going;
going = sqlcmd.Parameters.Add("@username", MySqlDbType.VarChar);
going.Direction = ParameterDirection.Input;
going.Value = Usrname.Text; */
try
{
while (daread.Read())
{
if (going.Value == Usrname.Text)
{
Password.Text = "........";
} else {
Password.Text = "not right";
}
}
} catch(MySqlException ex) {
throw new Exception(ex.Message);
} finally {
if (daread != null) daread.Close();
}
}
}
}
=========================================
this was my last attempt. i can get the values normally through the sqlcmd.GetString(0) and that works but i cant compare even with mysqlparameters :/.