Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all 1447 articles
Browse latest View live

Cannot use Parameter in Create User query (no replies)

$
0
0
Hello,

I'm trying to use the parameters for the following query:

CREATE USER 'user'@'host' IDENTIFIED BY 'password';

So I'm using a base query

CREATE USER @user@@domain IDENTIFIED BY @password;

but I'm unsuccessful and I get an error on @user@@domain parameter.

What I can do?

Regards

Information about mysqlhelper.escape() (1 reply)

$
0
0
Howdy,

About mysqlhelper.escape(), i'd like to know if it escapes only the quotes (') or escapes all characters like php's "mysqli->real_escape_string()" does, that escapes apart from "\" and "'": ASCII NUL, BACKSPACE, NEWLINE, CARRIAGE RETURN, TAB, CTRL-Z

Does it?
Would I be sabe using MySql.Data.MySqlClient.MySqlHelper.EscapeString() ?
(won't use parameters)

Thanks in advanced,

entity framework spatial support for multi-polygon and polygon (1 reply)

$
0
0
I use entity framework to access tables as follows:

CREATE TABLE `myplaces`
(

`Id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
`location` geometry DEFAULT NULL,

PRIMARY KEY (`Id`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;


the type of `location` column is geometry, mapping to the
CLR type `System.Data.Entity.Spatial.DbGeometry`

If I seed datas to the database by construct DbGeometry
such as DbGeometry.FromText("POINT(40.735031 -73.768387)"),
it works well.

However, when I construct DbGeometry such as
DbGeometry.FromText("POLYGON((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))"),
an IndexOutofRangeException was through out.

the stack trace show as follows:
於 MySql.Data.Entity.Metadata.NormalizeValue(TypeUsage type, Object value)
於 MySql.Data.Entity.SqlGenerator.Visit(DbConstantExpression expression)
於 System.Data.Entity.Core.Common.CommandTrees.DbConstantExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
於 MySql.Data.Entity.InsertGenerator.GenerateSQL(DbCommandTree tree)
於 MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
於 System.Data.Entity.Core.Common.DbProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree, DbInterceptionContext interceptionContext)
於 System.Data.Entity.Core.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
於 System.Data.Entity.Core.Common.DbProviderServices.CreateCommand(DbCommandTree commandTree, DbInterceptionContext interceptionContext)
於 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)

I have suyveyed how to access spatial with ef in MySQL. the samples are always
demoed with points. Does entity framework to mysql support accessing polygon or multi-polygon?

Requirements:

- OS windows:10

- Connector/Net 6.10.8.0

- Entity Framework 6.2.0 version

- .NET Framework 4.5.2 version

- Microsoft.SqlServer.Types 14.0.0.0

Using MYSQLDataAdapter to call MYSQL stored procedure for bulk insert/update/delete using data table (no replies)

$
0
0
All, I am new to MYSQL. I need a simple example that shows how VB.NET code can interact with MYSQL stored procedure using MYSQLDATAADAPTER. Requirement is to have one stored procedure retrieve data onto a VB.NET data grid and once user insert/modifies data within data grid, the same should be reflected into the database table by invoking stored procedure.

Would also need help with how the stored procedure should be coded.

Please help.

Your Project References the latest version of entity framework error (no replies)

$
0
0
I have a Visual Studio 2017 project that using Entity Framework 6.2

When trying to create the edmx file I get the error

"Your project references the latest version of Entity Framework; however, an Entity Framework database provider compatible with this version could not be found for you data connection"

I get this a lot but it is normally fixed by using he dlls from the connector installation folder. However this is not working anymore...

I am using MySql Community Server 8.0.12 and the same version of the connector dlls.

My App.config is as follows

<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity.EF6" />
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.12.0" newVersion="8.0.12.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

how on earth do I fix this issue?

MySQL .NET and Labview 2017 64bit (no replies)

$
0
0
Good Morning all,

Can anyone help me with the implementation of the .NET connector in National Instruments Labview.

I`m trying to set up a simple VI to which I can pass an SQL statement and, depending on that statement, return a string array of data.

So far i`ve not had any luck using the .NET connector for this. Below is the sequence from my attempt so far; (dataSet is created using System.Data.DataSet(String dataSetName)

Constructor - MySQLConnection,
Property Node - MySQLConnection(ConnectionString),
Property Node - MySQLConnection(OpenAsync),
Property Node - SqlDataAdaptor(SelectCommandText,SelectConnectionString),
Property Node - SqlDataAdaptor(Fill,dataSet)

I`m not sure what I should do next to read the data? Should I use MySQLCommand.ExecuteReader ? I`m guessing I would also need to use .NetObject to Variant and then Variant to Data?

Any help would be greatly received,

Nick

Connection Error - .NET Connector (5 replies)

$
0
0
Hi all,

Can anyone explain why i`m getting a `MySql.Data.MySqlClient.MySqlException: The host 192.168.20.151 does not support SSL connections.` from the MySQLConnection Open() command?

I`m using a simple connection string with the following;

server=192.168.20.151;uid=xxxxx;pwd=xxxx;database=xxxx

Our database does not have SSL enabled and I can`t see an option to specify whether to use SSL or not during connection.

Thanks in advance,

Nick

Re: MySQL Connector/NET 8.0.12 has been released (no replies)

$
0
0
Hi,

I use Mysql server v.8.0.12 and .NET connector 8.0.12.
I get several errors during inserts for strings into a varchar(45) field and Characater set utf8mb4. The table has charset utf8mb4, the database has charset utf8mb4.
The errors I get are all about:
Incorrect string value: '\\xE2\\x80\\xAC' for column 'VatNr' at row 1

How can I prevent these errors?

Unable to get CommandText (no replies)

$
0
0
Hi guys,

I’m a newcomer to MySQL. I'm using C# to connect a MySQL database. I can connect to it but I can't get information from it. I've tried few methods but it didn't work.

Here is connecting part.
MySqlConnection myConnection = new MySqlConnection();
myConnection.ConnectionString = "xxxx";
myConnection.Open();

Method 1:
MySqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = "SELECT count(*) FROM myTable";
label3.Text = myCommand.ExecuteScalar().ToString();

Method 2:
MySqlCommand myCommand = new MySqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = "SELECT count(*) FROM myTable";
label3.Text = myCommand.ExecuteScalar().ToString();

Method 3:
MySqlCommand myCommand = new MySqlCommand("SELECT count(*) FROM myTable", myConnection);
label3.Text = myCommand.ExecuteScalar().ToString();

Actually I can't tell difference from all of those methods, and all methods cannot execute. They throw a same exception when code execute myCommand.ExecuteScalar(). I set a breakpoint and found CommandText is null even when I set it as "SELECT count(*) FROM myTable".

Here is my exception:

MySql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=
Source=MySql.Data
StackTrace:
在 MySql.Data.MySqlClient.MySqlStream.ReadPacket()
在 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
在 MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
在 MySql.Data.MySqlClient.MySqlDataReader.NextResult()
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar()
在 Daily_Report.Form1.button_Generate_Click(Object sender, EventArgs e) 在 C:\Users\Administrator\Desktop\Daily Report\Daily Report\Form1.cs 中: 第 28 行
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 Daily_Report.Program.Main() 在 C:\Users\Administrator\Desktop\Daily Report\Daily Report\Program.cs 中: 第 19 行

I don't know why this happens, please help me find this. Thanks.

Any help would be greatly received,

Moon

SSIS Intermittent Failures (no replies)

$
0
0
I'm presenting this in two sections, a primary challenge which relates to stability of our SSIS packages using a 6.9.8 MySQL Connector and a secondary challenge as it relates to attempting to find a fix with version 8.0.12.

Primary Challenge and Context:

We have been running SSIS with MySQL Connector/.NET 6.9.8 for a number of years. The drivers have been rock solid pointing at a MySQL 5.6 database. However, we have recently migrated to AWS and have been pointing those same packages at an Aurora MySQL 5.6 source. Unfortunately, we are now having issues with stability. At times we get SSPI connection error: ADO NET Source has failed to acquire the connection {7F853977-C6C6-4F2B-847E-247BEFE953C2} with the following error message: “A call to SSPI failed, see inner exception." At other times, we see a hang condition whereby the SSIS package hangs and will eventually die after the timeout period elapses (8 hours). We can see that the specific Session ID in SSMS Activity Monitor shows the session in an Async_network_IO wait state. When we look on the Aurora/MySQL side of the connection, it shows that the query is complete and results have been returned, but the connection is remaining open. Other (non-SSIS) systems are using this Aurora/MySQL 5.6 without issue. Therefore, while we're not sure exactly what is causing this intermittent behavior, we believe that the MySQL Connector may be relevant. Both the SSPI and connection hang isseus are intermittent - we have 500+ packages that run daily using identical patterns and it's different packages on different days at different times - and sometimes they run for days without issue. When we manually re-run after failure, they usually run successfully. The connection hangs occur in MySQL SSIS Source components that hold straightforward, single table SELECTs that are streamed into dataflows.

Has anyone encountered a similiar scenario and found a fix? Or have experience narrowing down an issue like this? There are an impressive number of bug fixes related versions of the MySQL Connector/.NET since version 6.9.8 and 8.0.12 so we were hoping that upgrading to a newer version might resolve our issue. Unfortunately, that resulted in a different issue described below.

Secondary Challenge:

In an attempt to remediate the issue above, we upgraded our MySQL Connector to 8.0.12. Upon testing, we ran into an issue with some of the Execute SQL Task patterns that use the ADO.NET connection type. We are running a SELECT query in the task and storing the resultset in a variable. If we set the resultset to None, the package executes correctly but we use the resultset for subsequent processing. The error that comes back is: "Failed to create an IDataAdapter object. This provider may not be fully supported with the Execute SQL Task. Error message 'Object reference not set to an instance of an object.'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly." I have found others posting on forums that have run into a similar issue with this and report that 6.9.X of the driver work for this pattern, while 6.10.X and 8.0.X do not. We have hundreds of packages that use this pattern, so rebuilding them to use OLEDB or ODBC would be very challenging... and committing to this work is made more complex as we don't actually know if the driver upgrade will resolve the original issue.

Has anyone found a workaround for this? Or is it a known defect slated for bug fix in a future release?

ExecuteNonQuery() returns 0 if insert successful in both table! (no replies)

$
0
0
I think nothing's wrong with the connection because when I open it, it does not throw any error.

So I guess the error is when I'm executing a command through the store procedure.

From google ExecuteNonQuery() will return the row than affected during insert, update.

But my scenario will always get 0 if it is successful or not successful. Please correct me anything I'm wrong or misunderstand .

Please also suggest and the best way to achieve the result insert into two table. Thanks you


using (MySqlCommand cmd = new MySqlCommand("sp_insertlogin", sqlConn))
{
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@infristname", objsr.fristName);
cmd.Parameters.AddWithValue("@insurname", objsr.surName);
cmd.Parameters.AddWithValue("@inemailAddress", objsr.email);
cmd.Parameters.AddWithValue("@inphoneNumber", objsr.phone);
cmd.Parameters.AddWithValue("@inprofileImg", objsr.profileImg);
cmd.Parameters.AddWithValue("@inuserPass", objsr.password);

cmd.Parameters.Add(new MySqlParameter("id", MySqlDbType.Int32));
cmd.Parameters["id"].Direction = ParameterDirection.Output;

cmd.Parameters.Add(new MySqlParameter("userExits", MySqlDbType.Int32));
cmd.Parameters["userExits"].Direction = ParameterDirection.Output;

result = cmd.ExecuteNonQuery();

var outval = cmd.Parameters["@id"].Value;
var userExits = cmd.Parameters["@userExits"].Value;

if ((int)userExits == 2)
return 2;


return result;
}

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_insertlogin`(
IN infristName VARCHAR(300),
IN insurname VARCHAR(300),
IN inemailAddress VARCHAR(500),
IN inphoneNumber INT(11),
IN inprofileImg VARCHAR(300),
IN inuserPass VARCHAR(2000),
OUT id INT(11) ,
OUT userExits INT(11)
)
BEGIN

DECLARE EXIT HANDLER FOR SQLEXCEPTION rollback;
DECLARE EXIT HANDLER FOR NOT FOUND rollback;
DECLARE EXIT HANDLER FOR SQLWARNING rollback;


START TRANSACTION;

IF EXISTS (SELECT emailAddress FROM user_access.user_account where emailAddress = inemailAddress) THEN
SET userExits = 2;
SET id = 0;
ELSE
SET userExits = 0;
INSERT INTO user_access.user_account
(
fristName ,
surname ,
emailAddress ,
phoneNumber ,
profileImg
)
VALUES
(
infristname ,
insurname ,
inemailAddress ,
inphoneNumber ,
inprofileImg
);
SET id = LAST_INSERT_ID();


INSERT INTO user_access.user_profile
(
userAccount ,
password
)
VALUES
(
id ,
inuserPass
);

COMMIT;


END IF;

END

vesrions (1 reply)

$
0
0
Hi

I'm using the community server 5.7

1. which connector version should I use?
why there is no mapping table that maps the versions to be used?
(I'm using C++ connector ... however, the question is general
and true for all other languages - Python, Java, PHP)

2. Switching to Server 8.0 requires an upgrade of the connector?

Thanks

net core 2.1 code first out parameters does´t work (no replies)

$
0
0
I have to try to call stored procedure, with out parameter and its imposible, doesnt works,

for example:

var numRes = new MySql.Data.MySqlClient.MySqlParameter
{
ParameterName = "numResults",
DbType = System.Data.DbType.Int32,
Direction = System.Data.ParameterDirection.Output
};

dbcontext.Entity.fromSql("call procedure(@p1, @numResults")", var, numRes).toList();

where @numResultsits a out parameter

somebody have a solution?

thanks

Error while calling MysqlHelper.ExecuteNonQuery on a store procedure with a OUT parameter. (no replies)

$
0
0
Error when using MysqlHelper.ExecuteNonquery on a stored procedure with OUT parameter
----------
string string procSaveNotificationClickTime = "call test.save_user_alert_last_read_time(@p_user_id,@p_last_read_time,@r_return)";
string connectionString = ConfigurationManager.ConnectionStrings["testdb"].ConnectionString;
MySqlParameter[] parameters = new MySqlParameter[3];
parameters[0] = new MySqlParameter("@p_user_id", al.uid);
parameters[1] = new MySqlParameter("@p_last_read_time", lastReadTime);
parameters[2] = new MySqlParameter("@r_return", MySqlDbType.Int32);
parameters[2].Direction = ParameterDirection.Output;

retCode = MySqlHelper.ExecuteNonQuery(connectionString, procSaveNotificationClickTime, parameters);

----------

Get following error:"OUT or INOUT argument 3 for routine test.save_user_alert_last_read_time is not a variable or NEW pseudo-variable in BEFORE trigger"

run create store procedure by poweshell (1 reply)

$
0
0
I have .sql file which has multiple stored procedure, that run perfectly from mysql workbench and mysql command line tool example : source test.sql

test.sql

DROP procedure IF EXISTS `test`;

DELIMITER $$

CREATE PROCEDURE `test` ()
BEGIN
select * from organisations;
END$$


DELIMITER ;

DROP procedure IF EXISTS `test1`;

DELIMITER $$

CREATE PROCEDURE `test1` ()
BEGIN
select * from organisations;
END$$

DELIMITER ;
I have tried to execute same with powershell, but as i fond powershell doesn't recognized 'DELIMITER' keyword, so unable to run this via powershell.

Do we have any Azure DevOps release pipeline task which can run the test.sql? My requirement is to run the test.sql in Azure DevOps deployment pipleline. Any help Guys !!!

MySql stored procedure deployment in Azure DevOps (no replies)

$
0
0
Hi,
For Azure Devops release pipeline i need to execute .sql file which has multiple stored procedure.

Any ideas guys, how to do it. i have tried with MySqlTool Kits taskand Powershell but it fails because of Delimeter keywords.

occasional "The transaction has aborted." messages at client (no replies)

$
0
0
MySQL client application runs at Windows hosts, connects through .Net connector to a remote MySQL 5.6 26 db server (running at a Linux host).

Occasionally, at various client/app hosts a following message is recorded:
"The transaction has aborted."

No corresponding messages in the db server's error log file.

What are the recommended ways to investigate and resolve similar cases ?

Regards,
Avi Vainshtein

connection error to BD Mysql (1 reply)

$
0
0
hello, I made a program in C # for a supermarket, the office computer is the server with the DB and the box together with the server are connected to the same local wifi network, this is how the box connects to the DB, then the box starts session to start charging and everything is fine but after closing it and reopening it, the following error appears: "unable to connect to any specified mysql hosts", it only logs in once, from one moment to another when it returns to enter no longer leaves, help!

"SELECT * FROM bill WHERE year=wyear AND account >= waccount1 AND account

$
0
0
I am new to work with mysql 5.7.21 and c # and vs2015. How to display the rows from the BILL table in DataSet. When I do not put a condition in the WHERE, it shows me a complete table, but I need only some rows.

myConnectionString = pwput;
MySqlConnectionconpara = new MySql.Data.MySqlClient.MySqlConnection();
conpara.ConnectionString = myConnec DataSetionString;
try
{
conpara.Open();
if (conpara.State == ConnectionState.Open)
{
string waccount1 = wwaccount1.ToString();
string waccount2 = wwaccount2.ToString();
string upita = "SELECT * FROM bill WHERE year=wyear AND account >= waccount1
AND account <= waccount2";
MySqlCommandcmdnal = new MySqlCommand(nupita, con);
cmdnal.Parameters.AddWithValue("@year", wyear);
MySqlDataAdapte radda = new MySqlDataAdapter(cmdnal);
MySqlCommandBuilder cbb = new MySqlCommandBuilder(adda);
DataSet dsd = new DataSet();
adda.Fill(dsd, "bill");
conpara.Close();

if (dsd != null)
{
dataGridView1.DataSource = dsd;
dataGridView1.DataMember = "bill";
Font = new System.Drawing.Font("Arial Unicode", 7);
dataGridView1.Font = Font;

ERROR AL CONECTAR C# VISUAL STUDIO Y MYSQL (no replies)

$
0
0
CHICOS EL SIGUIENTE CÓDIGO ES DE UN TUTORIAL REALIZADO EN SQLSERVER, LO QUE HICE FUE PASAR LAS SENTENCIAS SQLSERVER A MYSQL. PERO CUANDO LO COMPILO ME SALE EL ERRRO.



Es en tres capas.

Capa_Conexion datos

Clase. Conexion_Data

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 consul_user

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

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;
}
}
}


Capa_formularios

Codifo evento click. de boton

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(); //(X) EXEPCION NO CONTROLADA // ***//
if (LogUser.Read() == true)
{
this.Hide();
menuform fmrPrr = new menuform();
fmrPrr.Show();

}
else
MessageBox.Show("Usuarios Invalidos");
}

//**// EXCEPCIÒN NO CONTROLADA.

MySql.Data.MySqlClient.MySqlExcepcion:' You have an erro in your SQL Sintax; check the manual that corresponds to your MySql server version for the rigth sintaxis to usear near' Formulario where name_user= ADMINSYS AND PASS_user=1234567' at line 1.

ese es el mensaje cuando se compila el codigo en Visual Studio.
Viewing all 1447 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>