ERROR LOGIN C# Y MYSQL SERVER 5.7
Publicado por LUIS (1 intervención) el 06/11/2018 20:49:58
uenas noches chisco les quiero mostrar un ensayo de un tutorial de un login, pero inicialmente esta en C# y Sqlserver, pero lo estoy pasando a Mysqlserver version 5.7, pero el problema es que no me compila.
Es en tres capas.
Capa_Conexion datos.
CLASE CONSULT_USER
CAPA COMERCIO
CLASE CONEXION_USER
EVENTO CLICK
PERO CUANDO COMPILA, GENERA LA SIGUIENTE EXEPCIÒN.

Es en tres capas.
Capa_Conexion datos.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using MySql.Data.MySqlClient;
namespace Capa_Datos
{
class Conexion_data
{
private MySqlConnection conect = new MySqlConnection("Server=localhost;Database=cont_data;Uid=root;Pwd=Lhr310528;");
public MySqlConnection openconect()
{
if (conect.State == ConnectionState.Closed)
conect.Open();
return conect;
}
public MySqlConnection closconect()
{
if (conect.State == ConnectionState.Open)
conect.Close();
return conect;
}
}
}
CLASE CONSULT_USER
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using MySql.Data.MySqlClient;
namespace Capa_Datos
{
public class Consult_User
{
private Conexion_data conect = new Conexion_data();
private MySqlDataReader read;
public MySqlDataReader ConsultUser(string user, string password)
{
string qry = "Select * FROM long_cont where name_user='" + user + "' and pass_user='" + password+"'";
MySqlCommand command = new MySqlCommand();
command.Connection = conect.openconect();
command.CommandText = qry;
read = command.ExecuteReader();
return read;
}
}
}
CAPA COMERCIO
CLASE CONEXION_USER
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using MySql.Data;
using Capa_Datos;
namespace Capa_Negocios
{
public class Conexion_User
{
private Consult_User DateUSer = new Consult_User();
//Variables
private string _user;
private string _password;
// Sepuede Agregar las Necesarias para validar el correcto acceso al sistema
public String SysUser
{
set { _user = value; }
get { return _user; }
}
public String Syspassword
{
set { _password = value; }
get { return _password; }
}
//COnstructor
public Conexion_User() { }
//Funcion Metodos
public MySqlDataReader Logsys()
{
MySqlDataReader LogUser;
LogUser = DateUSer.ConsultUser(SysUser, Syspassword);
return LogUser;
}
}
}
EVENTO CLICK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private void btn_log_Click(object sender, EventArgs e)
{
Conexion_User acceso = new Conexion_User();
MySqlDataReader LogUser;
acceso.SysUser = txt_user.Text;
acceso.Syspassword = txt_pass.Text;
LogUser = acceso.Logsys();
if (LogUser.Read() == true)
{
this.Hide();
menuform fmrPrr = new menuform();
fmrPrr.Show();
}
else
MessageBox.Show("Usuarios Invalidos");
}
PERO CUANDO COMPILA, GENERA LA SIGUIENTE EXEPCIÒN.

Valora esta pregunta


0