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

BulkLoad with Composite Primary Key (2 replies)

$
0
0
Is there some trick to bulkloading a table that has a composite primary key?

Scenario is this: Using Visual Studio C# I am able to do a bulk load when the primary key is set to a single Auto-increment column (ID). Works fine and useful for early testing. Table size in test exceeds 100M rows so bulk load is a requirement.

The actual Primary key is a composite of two columns that are both not null and the combination of which will always be unique (guaranteed due to the data creation algorithm).

Yet when I try to load the table with the composite primary key defined, bulk load only loads a single row with both elements of the primary key zeroed out. Huh.

I've verified:
- data going in - the values in the key columns are always completed.
- Table definition in MySQL. Keys are correctly listed as part of primary
- everything works fine if I use the Unique non-composite ID key.

I have no use for the Unique ID column so a primary key or index there seems completely unecessary.

Any ideas?

Too Many Connections - ADO.NET pooling issues (C#) (1 reply)

$
0
0
I am using a combination of ADO.NET and C# with a MySQL database and I have an intermittent issue that has been occurring for a couple of years.

My hosting allows a maximum of 30 concurrent MySQL connections and pooling is enabled. However, occasionally on both low/high traffic days - I get the error 'max_user_connections' and I'm unable to connect to the database (as this point, I need to ask my webhost to clear them down to regain access). When these are cleared down, it sometimes fixes the problem and sometimes it happens again shortly after.

And then everything can be fine for days/weeks (but it always occurs again at some point). My webhost has confirmed my site is the only site with active connections.

Here is my connection code:

public class MySQL
{
private static string connectionString = ConfigurationManager.ConnectionStrings["MySQLConnectionInfo"].ConnectionString;

public class Get
{
public static DataTable GetDataTableUsingParms(string inSQL, List<dbParm> inParms, string from = null)
{
try
{
using (MySqlConnection myConnection = new MySqlConnection(connectionString))
{
using (MySqlCommand myCommand = new MySqlCommand(inSQL, myConnection))
{
foreach (dbParm inParm in inParms)
{
MySqlParameter currentParm = new MySqlParameter();

currentParm.ParameterName = inParm.ParmName;
currentParm.Value = inParm.ParmValue;

myCommand.Parameters.Add(currentParm);
}

DataTable myDataTable = new DataTable();
using (MySqlDataAdapter myAdapter = new MySqlDataAdapter(myCommand)) {
myAdapter.Fill(myDataTable);
}

return myDataTable;
}
}
}
catch (MySql.Data.MySqlClient.MySqlException err)
{
throw new System.Exception(err.ToString());
}
catch (System.TimeoutException err)
{
throw new System.Exception(err.ToString());
}
catch (System.Exception err)
{
throw new System.Exception(err.ToString());
}
}
}
}

Can anyone advise where to look next? I'm at a total loss.

Driver replacements (no replies)

$
0
0
Hello All,

Are there any third party (paid or free) drivers that can replace the native drivers that you know of and/or that you've used successfully are happy with it?

I need a very high performing driver that can handle very very high volume of data throughput and is extremely reliable and configurable.

Thanks/SH

MySQL Connector/NET 8.0.21 has been released (no replies)

Found nothing on stackoverflow. HELP!! (no replies)

$
0
0
I am trying to update a cell which is selected based on 2 functions. One function selects rows randomly and the other selects columns randomly. Whatever value the cell may hold has to be replaced with NULL. There has to be one NULL cell in 10% of the rows.

The code is as follows:

entry=(cols,empty_rows)
cur.execute("update pkg_info set %s=NULL where pkg_id=%s",entry)
The exact error is as follows:

mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''isDeliverable'=NULL where pkg_id=8' at line 1
I suspect the problem is that the column name (isDeliverable in this case) is enclosed within quotation marks. Other possible problems and solutions are welcome.

Thanks all in advance!

ADO.NET Entity Data Model not creating model (no replies)

$
0
0
Context : I have a mySQL server running in AWS, and am attempting to interface with it via a WinForms application.

I am able to connect to the db with mySQL workbench without issue.

Problem (in sequence to reproduce):

1) Right click project -> Add -> New Item
2) Under the Data category, I choose ADO.NET Entity Data Model
3) EF Designer from Database
4) Here I choose a new connection, the datasource field indicates "MySQL Database (MySQL Data Provider)"
5) I enter the credentials, endpoint, etc, connection succeeds
6)
Here is the problem. It asks what version of the entity framework I would like to use, but instead of active radio buttons stating EF6 or EF5, I am given the following 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 your data connection. If you have already installed a compatible provider, ensure you have rebuilt your project before performing this action. Otherwise, exit this wizard, install a compatible provider, and rebuild your project before performing this action. Learn more about this"

Obviously, one would think the solution is to install an Entity Framework database provider. The problem is I have one installed.

Things I have done to attempt to fix this :

1) Re-install Visual Studio 2017
2) Re-install MySQL community, and all associated addons (.net connector and visual studio plugin)

At this point no error message was displayed after hitting next, the dialog box would simply close, and generate a DB connection, but no actual model.

3) Installed all packages made by MySQL
4) Tried almost every combination of packages posted by MySQL
5) Re-installed the connector with the MySQL installer, and rebooted, about 4 times.
6) Used REVO uninstaller to absolutely destroy every single trace of mySQL and Visual Studio 2017 on my computer including registry entries



I have followed every instruction I could find as thoroughly as possible and have spent my entire morning dealing with this issue. At this point I have tried the same thing (nuke studio+mySQL and reinstall) way too many times, and I am now turning to these forums for some advice. I just wanted to use Entity Framework instead of old fashioned writing db context + code stuff myself.

If it matters to know, my Visual Studio installation is on C drive and projects on D but this has never affected anything before. I am on W10.

Slow filling data (no replies)

$
0
0
Why filling in data when using MySQL Connector/Net works 10-20 times slower than when using a ODBC connector OdbcDataAdapter Fill()? The body of the query or stored procedure is the same.
This effect is observed when using the methods MySqlDataAdapter Fill() and DataTable Load() from MySqlDataReader.
Version of Connector/Net - 6.9.1
Version of Connector ODBC - 5.1
None of the recommendations that I found on the Internet affect this in any way. For example, DataSet property EnforceConstraints = false and DataTable methods
BeginLoadData() and EndLoadData().

Windows Server 2016 Connection Issues (2 replies)

$
0
0
I have installed and configured MySQL server 8.0.20. When I try to connect to this server with my application I get a connection time out error. If I up the time out I get a "Can't connect to this server". I am 100% sure the connection string is correct. I have also upgraded to the newest version 8.0.21, but with no luck.

One thing I have noticed is that when I try to configure the MySQL server through the MySQL Installer, it hangs for a few seconds and fails to connect on the check connection step. The weird thing is that this only happens the first time, if I immediately do it again the check is successful. If I use the MySQL shell or Workbench it connects successfully on the first attempt. I have tried turning off the firewall, but this didn't help. It seems to me that something is blocking the connection, but I have no idea what.

When I run this on my local machine (Windows 10) everything works perfectly, but when I run it on my Windows Server 2016 this issue occurs.

Do you have any idea what the problem is or how to fix this?

Stored procedure exception - Nuget Mysql.Data 8.0.21.0 (1 reply)

$
0
0
Hi,
with nuget package mysql.data (version 8.0.21.0), I receive an exception "MySqlException: Incorrect routine name ''" when I try to access a stored procedure.

If I get back to the version 8.0.20.0 all is working well.

It's a bug or how can I solve this problem?

Thank you for your support.

Create Stored Procedure (3 replies)

$
0
0
hello,

Anyone have any idea how to create a stored procedure with c# or vb.net?

My code is as follows, but it shows a syntax error and from workbench it runs without errors.


*****************************************************
String query = "USE `databasename`;";
query += " DROP procedure IF EXISTS `sp_create`;";
query += " DELIMITER $$";
query += " CREATE DEFINER=`user`@`%` PROCEDURE `sp_create` (";
query += " in vId int(11), in vfName varchar(150)";
query += " )";
query += " BEGIN";
query += " INSERT INTO Contacts (Id, fName)";
query += " VALUES (vId, vfName);";
query += " SELECT LAST_INSERT_ID() AS IdRegistro;";
query += " END$$";

ExecuteCommand(query);


private static void ExecuteCommand(string queryString,
string connectionString)
{
using (SqlConnection connection = new SqlConnection(
connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}

**********************************


thanks,

8.1 Entity Framework 6 Support -- problem (no replies)

$
0
0
In my MVC5 EF6 Code First app, in the root Web.Config, I used the connectionString and provider shown at https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html . Except that I used the actual server where the MySQL databases are, and the name of the actual database, along with my full privilege service account for uid and password.

When I try to create a Controller for one of the Models, I get this Error: There was an error running the selected code generator:
'Unable to retrieve metadata for 'TestUniversity.Models.Student' Using the
same DbCompiledModel to create contexts against different types of database
servers is not supported. Instead, create a separate DbCompiledModel for each
type of server being used.

Is this because of the version of the MySQL database? It is 5.6.13

I received this reply:
this looks like an issue with MySQL Connector/NET. I recommen posting your question in the following forum: https://forums.mysql.com/list.php?38

So here I am. Can you help?
Thank you

Strange performacne issue after upgrading to 8.0.21 (no replies)

$
0
0
I've upgraded mysql on windows server to 8.0.21 version.

I have a query that runs 7s using the connector / navicat client both on localhost and remotely.

Same query runs 0.9 on Workbench.

Query returns 1 row.

explain:
Select type: Simple
Type: ALL
Possible keys: cola-colb
key: null
key_lenn: null
rows: 10M
filtered: 16.66
Extra:
using WHERE.

Something is wrong in the connector to this server's version.

table has 10M records and it's on INNODB:

CREATE TABLE `e` (
`cola` decimal(39,0) unsigned DEFAULT NULL,
`colb` decimal(39,0) unsigned DEFAULT NULL,
`a` char(2) COLLATE utf8_bin DEFAULT NULL,
`b` varchar(64) COLLATE utf8_bin DEFAULT NULL,
`c` varchar(128) COLLATE utf8_bin DEFAULT NULL,
`d` varchar(128) COLLATE utf8_bin DEFAULT NULL,
KEY `idx_ip_cola_colb` (`cola`,`colb`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin

and query is:

SELECT a, b, c FROM e WHERE cola <= 281471982716236 and 281471982716236 <= colb;

MS Build warnings from MySQL.Data dll with Win10 (Community Edition) (no replies)

$
0
0
Hello,
Am using Community Edition 8.0.21 and Connector .NET 8.0.21 on Windows 10.

Turns out that, since a few Connector.NET releases, I see a whole bunch of warnings when building my project(s) which use MySQLData dll and are written with VB.NET.

Basically, these warnings refer to the use of Windows system files such as System.IO, System.Tracing etc....

According to Microsoft, these dependencies are generated from MySQL.Data.
Nothing weird except that packaging the project increases its size dramatically and that system files are protected by the OS anyway.

Are you aware of such an issue

Am available to send you any shots you may need.

Cheers

Philippe

How can I get MySqlCommand to play nicely with .NET Core? (3 replies)

$
0
0
I've got a .NET Framework program that I'm trying to run on .NET Core. It uses MySql 4.5.4. When I try and open a connection:

MySqlConnection conn = new MySqlConnection(connectionStringToDB);
conn.Open();
it crashes on the conn.Open() line with this exception:

WpfApp2 Error: 0 : 'Windows-1252' is not a supported encoding name.
For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')
Exception thrown: 'System.ArgumentException' in MySql.Data.dll An unhandled exception of type 'System.ArgumentException' occurred in MySql.Data.dll
'Windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

I'm out of my depth -- can anyone shed light on this, and how to get around it?

.NetCore client connection throwing " Unable to connect to any of the specified MySQL hosts." (1 reply)

$
0
0
On a system that processes 500,000 requests daily (i.e. very moderate workload) running against an AWS Aurora RDS database server, very unexpectedly in that last two weeks we have gotten a storm of these errors. We've been using Aurora for years. This particular version of our client app [IIS Worker Process] has been in production for several weeks without any changes (the core code unchanged in years).

Can someone tell me what would CAUSE this error?

We have two Windows 2016 systems running four client app instances. Only one instance experienced this error and only resolved after a restart of the IIS worker process.

Since the other instances continued to work without any issues, it doesn't seem like a networking issue. The ADO connection pool is standard default and the logs showed no errors of interest - just suddenly started getting these errors.


Oracle MySql.Data.MySqlClient .Net Core Class Library 8.0.20

MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data....'

Any guidance in tracking down root cause or better configuration would be welcome.

Thanks

MySQL Connector/NET 8.0.22 has been released (no replies)

Option not supported. Parameter name: SSH Passphrase (no replies)

$
0
0
Trying to use the .NET MySQL connector to create an SSIS Package.

When I try to test the connection, it gives this error:
TITLE: Connection Manager
------------------------------

Test connection failed because of an error in initializing provider. Private key is encrypted but passphrase is empty.

------------------------------
BUTTONS:

OK
------------------------------


When I try to enter the passphrase in the Connection Manager, it gives this error:
Option not supported. Parameter name: SSH Passphrase

Performance issue (no replies)

$
0
0
Hello
Reading database is very slow.
I'm using Connector 8.0.22.0
After profiling it I found that 90% of all time is lost on regex ctor.
Class:
MySql.Data.MySqlCLient.NativeDriver
Method:
public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
Line:
Regex regex = new Regex("(?i)^[0-9A-F]{8}[-](?:[0-9A-F]{4}[-]){3}[0-9A-F]{12}$");

It is huge time loss on each value read. And if I understood correctly this regex is used only with guid column types which I don't have.

Please check it out

Error in Collection.ReplaceOne method (1 reply)

$
0
0
I have a DbDoc with the following structure:
{
͏͏ property1: value1,
 property2: value2.
 array3:
  [
   {
    property11: value11,
    property12: value12
   },
   {
    property11: value11,
    propertu12: value12
   }
  ]
}

When I add this DbDoc using Collection.Add(DbDoc) method, it works.
But when I try to update the database document using Collection.ReplaceOne(id,DbDoc) method, I get the following exception:

System.NotSupportedException
HResult=0x80131515
Mensaje = Value of type System.Collections.Generic.Dictionary`2[System.String,System.Object][] is not currently supported.

Can anybody tell me what am I doing wrong?

1146 error Table does not exist EF 6 add schema.schema.tablename prefix (no replies)

$
0
0
hi, i am trying to execute this code in asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFSample
{
class Program
{
static void Main(string[] args)
{
try
{
using (cursomvcEntities db = new cursomvcEntities())
{
var lst = from d in db.user
where d.email == "gsefren@gmail.com" && d.password == "1234567" && d.idstate == 1
select d;
if (lst.Count() > 0)
{
user Ouser = lst.First();
Console.Write("Si entro");
}
else
{
Console.Write("No entro");
}
}
}
catch (Exception ex)
{
Console.Write("Ocurrió un error :( " + ex.Message);
}
}
}
}
but give me an error the table cursomvc.cursomvc.user does not exist

i generate the Model from Database First i dont know how or why EF add twice cursomvc i really apreciate your help
Viewing all 1447 articles
Browse latest View live


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