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

VB2010 How to determine who is connected to database (no replies)

$
0
0
Using VB, I was wondering what SQL command I could send to the database that would return which users were connected to a database, connection date/time and computer name they are using? If a MySQL instance has more than one database, is it also possible to know which database they are using?

TIA, rasinc

Connector 6.9 + EF6 + Mono + Linux crash on startup (no replies)

$
0
0
Hi.

I'm trying to use the mysql connector with mono under linux but I can't get it to work, always get this exception:

minLength is greater than maxLength. Related schema item SourceUri: , Line 363, Position 14. - at System.Xml.Schema.ValidationHandler.RaiseValidationEvent (System.Xml.Schema.ValidationEventHandler,System.Exception,string,System.Xml.Schema.XmlSchemaObject,object,string,System.Xml.Schema.XmlSeverityType) <0x000ec>
at System.Xml.Schema.XmlSchemaObject.error (System.Xml.Schema.ValidationEventHandler,string,System.Exception,System.Xml.Schema.XmlSchemaObject,object) <0x0004f>
at System.Xml.Schema.XmlSchemaObject.error (System.Xml.Schema.ValidationEventHandler,string) <0x0003f>
at System.Xml.Schema.XmlSchemaSimpleTypeRestriction.checkMaxLengthFacet (System.Xml.Schema.XmlSchemaMaxLengthFacet,System.Xml.Schema.XmlSchemaFacet/Facet,System.Xml.Schema.ValidationEventHandler) <0x007df>
at System.Xml.Schema.XmlSchemaSimpleTypeRestriction.Validate (System.Xml.Schema.ValidationEventHandler,System.Xml.Schema.XmlSchema) <0x00aef>
at System.Xml.Schema.XmlSchemaSimpleType.Validate (System.Xml.Schema.ValidationEventHandler,System.Xml.Schema.XmlSchema) <0x000df>
at System.Xml.Schema.XmlSchemaAttribute.Validate (System.Xml.Schema.ValidationEventHandler,System.Xml.Schema.XmlSchema) <0x001d7>
at System.Xml.Schema.XmlSchemaUtil.ValidateAttributesResolved (System.Xml.Schema.XmlSchemaObjectTable,System.Xml.Schema.ValidationEventHandler,System.Xml.Schema.XmlSchema,System.Xml.Schema.XmlSchemaObjectCollection,System.Xml.Schema.XmlSchemaAnyAttribute,System.Xml.Schema.XmlSchemaAnyAttribute&,System.Xml.Schema.XmlSchemaAttributeGroup,bool) <0x0076b>
at System.Xml.Schema.XmlSchemaAttributeGroup.Validate (System.Xml.Schema.ValidationEventHandler,System.Xml.Schema.XmlSchema) <0x001fb>
at System.Xml.Schema.XmlSchema.Validate (System.Xml.Schema.ValidationEventHandler) <0x00357>
at System.Xml.Schema.XmlSchemaSet.Compile () <0x0070f>
at System.Data.Entity.Core.SchemaObjectModel.Schema/SomSchemaSetHelper.ComputeSchemaSet (System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption) <0x00187>
at System.Data.Entity.Core.Common.Utils.Memoizer`2/<>c__DisplayClass2<System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption, System.Xml.Schema.XmlSchemaSet>.<Evaluate>b__0 () <0x0002b>
at System.Data.Entity.Core.Common.Utils.Memoizer`2/Result<System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption, System.Xml.Schema.XmlSchemaSet>.GetValue () <0x00077>
at System.Data.Entity.Core.Common.Utils.Memoizer`2<System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption, System.Xml.Schema.XmlSchemaSet>.Evaluate (System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption) <0x001df>
at System.Data.Entity.Core.SchemaObjectModel.Schema/SomSchemaSetHelper.GetSchemaSet (System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption) <0x0002f>
at System.Data.Entity.Core.SchemaObjectModel.Schema.CreateXmlReaderSettings () <0x000f3>
at System.Data.Entity.Core.SchemaObjectModel.Schema.Parse (System.Xml.XmlReader,string) <0x00027>
at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate (System.Collections.Generic.IEnumerable`1<System.Xml.XmlReader>,System.Collections.Generic.IEnumerable`1<string>,System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption,System.Data.Entity.Core.SchemaObjectModel.AttributeValueNotification,System.Data.Entity.Core.SchemaObjectModel.AttributeValueNotification,System.Data.Entity.Core.SchemaObjectModel.ProviderManifestNeeded,System.Collections.Generic.IList`1<System.Data.Entity.Core.SchemaObjectModel.Schema>&) <0x0025f>
at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate (System.Collections.Generic.IEnumerable`1<System.Xml.XmlReader>,System.Collections.Generic.IEnumerable`1<string>,System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption,System.Data.Entity.Core.Common.DbProviderManifest,System.Collections.Generic.IList`1<System.Data.Entity.Core.SchemaObjectModel.Schema>&) <0x001ff>
at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.LoadItems (System.Collections.Generic.IEnumerable`1<System.Xml.XmlReader>,System.Collections.Generic.IEnumerable`1<string>,System.Data.Entity.Core.SchemaObjectModel.SchemaDataModelOption,System.Data.Entity.Core.Common.DbProviderManifest,System.Data.Entity.Core.Metadata.Edm.ItemCollection,bool) <0x00077>
at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection.Init (System.Collections.Generic.IEnumerable`1<System.Xml.XmlReader>,System.Collections.Generic.IEnumerable`1<string>,bool) <0x00057>
at System.Data.Entity.Core.Metadata.Edm.EdmItemCollection..ctor (System.Collections.Generic.IEnumerable`1<System.Xml.XmlReader>,System.Collections.Generic.IEnumerable`1<string>,bool) <0x000cb>
at System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadEdmItemCollection (System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoader) <0x0007b>
at System.Data.Entity.Core.Metadata.Edm.MetadataCache/<>c__DisplayClass5.<GetMetadataWorkspace>b__0 (string) <0x0005f>
at System.Collections.Concurrent.ConcurrentDictionary`2<string, System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace>.GetOrAdd (string,System.Func`2<string, System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace>) <0x00067>
at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace (string,System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoader) <0x00107>
at System.Data.Entity.Core.Metadata.Edm.MetadataCache.GetMetadataWorkspace (System.Data.Entity.Core.EntityClient.Internal.DbConnectionOptions) <0x0006f>
at System.Data.Entity.Core.EntityClient.EntityConnection.GetMetadataWorkspace () <0x00043>
at System.Data.Entity.Core.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection () <0x00033>
at System.Data.Entity.Core.Objects.ObjectContext..ctor (System.Data.Entity.Core.EntityClient.EntityConnection,bool,System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory,System.Data.Entity.Core.Common.Internal.Materialization.Translator,System.Data.Entity.Core.Query.InternalTrees.ColumnMapFactory) <0x004cf>
at System.Data.Entity.Core.Objects.ObjectContext..ctor (System.Data.Entity.Core.EntityClient.EntityConnection) <0x00037>
at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel () <0x000e7>
at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel () <0x0001b>
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext () <0x0016b>
at System.Data.Entity.Internal.InternalContext.Initialize () <0x0001b>
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType (System.Type) <0x00017>
at System.Data.Entity.Internal.Linq.InternalSet`1<UcarusBackOffice.SesionCliente>.Initialize () <0x0004b>
at System.Data.Entity.Internal.Linq.InternalSet`1<UcarusBackOffice.SesionCliente>.Include (string) <0x00023>
at System.Data.Entity.Infrastructure.DbQuery`1<UcarusBackOffice.SesionCliente>.Include (string) <0x00073>
at UcarusClientApi.Classes.Utils.RecuperaSesion (UcarusBackOffice.Entities,SDRestFramework.RESTRequest) <0x00107>
at UcarusClientApi.Resources.DeviceManagement.DeviceAlertTransports (SDRestFramework.RESTRequest) <0x0007f>
at UcarusClientApi.Resources.DeviceManagement.GetProcessor (SDRestFramework.RESTRequest) <0x000ff>
at (wrapper dynamic-method) object. (object,object[]) <0x0006b>
at SDRestServer.SDRestServerCommon.ExecuteRequest (SDRestFramework.RESTRequest,SDRestFramework.RESTResourceInfo[],SDRestFramework.RESTRequestFilter[],SDRestFramework.RESTResourceFilter[],SDRestFramework.RESTResponseFilter[]) <0x0060b>


I have checked my ADO data model, used external metadata files and nothing has the maxlength or minlength in the line 363, and by the exception it seems it's something on the provider metadata definition.

My mono version is 4.0.0 and my project is compiled with framework V4.5.

Any ideas?

Upgrading MySql.Data.Entity to version 6.9.6 breaks database models (1 reply)

$
0
0
Hello
After upgrading MySql.Data and MySql.Data.Entity NuGet packages to version 6.9.6 validation of my database model fails.

I get the following error message on all fields that are defined as nullable in the actual database table:
"Error 13101: Key part '[Property name]' for type '[Entity name]' is not valid. All parts of the key must be non-nullable."


None of the properties listed in the error list are defined as "Entity keys"
Does anyone know how to deal with this? I wish I could just define all the properties as non-null in the MySQL database, but that's gonna affect other production systems.
Reverting to 6.9.5 is really not an option, as I'm not even able to update the model using that version on my Windows 10 dev machine.

oracle select from MySQL with SSL connection failing ERROR 2026 (HY000) (no replies)

$
0
0
Exiting hgogenconstr, rc=0 at 2015/05/22-12:06:47
Entered hgopoer at 2015/05/22-12:06:47
hgopoer, line 231: got native error 2026 and sqlstate HY000; message follows...
[MySQL][ODBC 5.1 Driver]SSL connection error {HY000,NativeErr = 2026}
Exiting hgopoer, rc=0 at 2015/05/22-12:06:47
hgocont, line 2831: calling SqlDriverConnect got sqlstate HY000
Exiting hgocont, rc=28500 at 2015/05/22-12:06:47 with error ptr FILE:hgocont.c LINE:2851 FUNCTION:hgocont() ID:Something other than invalid authorization
Exiting hgolgon, rc=28500 at 2015/05/22-12:06:47 with error ptr FILE:hgolgon.c LINE:806 FUNCTION:hgolgon() ID:Calling hgocont
hostmstr: 0: HOA After hoalgon
RPC Calling nscontrol(0), rc=0
hostmstr: 0: RPC Before Exit Agent
hostmstr: 0: HOA Before hoaexit
Entered hgoexit at 2015/05/22-12:06:47
Exiting hgoexit, rc=0
hostmstr: 0: HOA After hoaexit
hostmstr: 0: RPC After Exit Agent

got error when i try to connect to MySQL (no replies)

$
0
0
hi

i have C# WinForm program and i try to connect to MySQL 5.6

on my DataSet.xsd i got this error:

Failed to open a connection to the database
"Cannot obtain provider factory for data provider named
'MySq.Data.MySqlClient'
Check the connection and try again.

MysqlDataAdapter batch update (no replies)

$
0
0
What is the intended purpose of MySqlDataAdapter.UpdateBatchSize for inserted rows while calling Update?

1) My intuitive understanding was that it should construct single insert statement containing multiple values. Also internal property called batchableCommandText looked promising. Unfortunately updating table with new lines just issues "a batch of" single line inserts. Is that intended behaviour?

2) Looks like batchableCommandText content is not used for anything, just for null comparisons. Is that intended? Did I miss something?

Cant uninstall mysql-connector-net-6.9.6 (1 reply)

$
0
0
I downloaded Windows (x86, 64-bit), ZIP Archive (mysql-5.6.25-winx64.zip) , and i installed all packs what was available. Yesterday i was cleaning my computer and then i accidentally removed all MySql files. Then i goed to control panel and removed all of them but i couldnt remove Mysql connector net 6.9.6, it start to go removing it but then it stop it. And i cant repair it because i dont have any files.

storing connection parameters for Windows app using MYSQL (1 reply)

$
0
0
Does anyone know of how I shoulid go about storing connection parameters (ie. server name/IP, database user name, database user password, database name, etc) on a Windows computer for use by the program I'm working on?

I'm writing a database app (Windows desktop app, not web app or Windows store app) that will use MySQL and need to access it, however, I want to make it so that if the database is moved (or the name is changed, or username changed, or password is changed) that within my program, the user can go in and change the parameters to connect using the new connection parameters.

My question is where should I store this, and how can I do it securely (mainly the username and password). The other stuff could be stored in plain text. I have heard there are ways to store an encrypted string (probably only 128-bit) into the registry.

Suggestions or ideas? How do other programs do it? I don't really want to hard-code the parameters as it would be troublesome if and when the program is distributed, so I'd rather have them be customizable from the app itself.

The handshake failed due to an unexpected packet format (no replies)

$
0
0
I am trying to use mysqlconnector to connect with SSL to my database. I get the error in the title. I am using version 6.9.6 of the connector.

**my.cnf**

[mysqld]
ssl
ssl-ca=/etc/mysql/ca.pem
ssl-cert=/etc/mysql/server-cert.pem
ssl-key=/etc/mysql/server-key.pem
ssl-capath=/etc/mysql/
ssl-cipher=DHE-RSA-AES256-SHA

**Showing that SSL is enabled.**

+---------------+----------------------------+
| Variable_name | Value |
+---------------+----------------------------+
| have_openssl | YES |
| have_ssl | YES |
| ssl_ca | /etc/mysql/ca.pem |
| ssl_capath | /etc/mysql/ |
| ssl_cert | /etc/mysql/server-cert.pem |
| ssl_cipher | DHE-RSA-AES256-SHA |
| ssl_key | /etc/mysql/server-key.pem |
+---------------+----------------------------+
7 rows in set (0.00 sec)


I can connect locally with the following command.

mysql --ssl-ca=ca.pem --host=127.0.0.1 --user=ocnuser --password

I can verify my connection has encryption after logging in, with that command.


+---------------+--------------------+
| Variable_name | Value |
+---------------+--------------------+
| Ssl_cipher | DHE-RSA-AES256-SHA |
+---------------+--------------------+
1 row in set (0.01 sec)

However, using this VB.NET code, I cannot open a connection.

Dim MysqlConn As MySqlConnection
Dim connStr As String = "server=192.168.1.2;user id=ocnuser;password=passwordgoeshere;database=OCN;Certificate Store Location=CurrentUser;SSL Mode=Required"
Dim msc As New MySqlConnection
Try
msc.Open()
Catch ex As Exception
MsgBox("There was a problem connecting to the database.", MsgBoxStyle.Exclamation)
End Try

I can connect with MySQL Workbench from a remote PC, assuming I point to the CA File.

Perhaps I imported the wrong file to my store. Which file am I supposed to import in order to make a connection? I also do not have any client certs or keys (was instructed I didn't need them for my situation). I also have read .NET doesn't do .PEM, but .PFX.

I also got `error 18 at 0 depth lookup:self signed certificate` when I ran `openssl verify` on my `server-cert.pem`. Not sure if that has anything to do with this.

Object reference not set to an instance of an object. (1 reply)

$
0
0
At the development end I am using Visual Studio 2013 and MySQL 5.6.25 and MySQL Connector .NET 6.9.
I have taken an off the peg example of the new(ish) alternative to ASP.NET Membership with OWIN features and have altered the plumbing to use MySQL instead of MS SQL Server and it works just fine.
But: When I publish this up to our (cheap as chips) hosting provider it craps out with the message 'Object reference not set...'.
The hosting company environment is (apparently) IIS7.5 along with MySQL 5.5.33.
I have tried so many things that I've lost track of the changes I have made.

Please - don't read on to the next one if you can help.
All suggestions welcomed.

Is altering stored procedures supported with EF 6? (no replies)

$
0
0
Is altering stored procedures currently supported?

Am using Visual Studio 2013, EF 6, MySQl Server 5.6, and MySQL Connecter Net 6.9.6.

I have a migration that is attempting to alter a stored procedure.

Using the Package Manager Console, Add-Migration works. Update-database does not.

It throws this exception:

System.NotImplementedException: AlterProcedureOperation
at MySql.Data.Entity.MySqlMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorScriptingDecorator.ScriptUpdate(String sourceMigration, String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScriptUpdate(String sourceMigration, String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
AlterProcedureOperation

The migration code it is failing with this migration.cs file:

public partial class RowVersion : DbMigration
{
public override void Up()
{
AddColumn("dbo.Department", "RowVersion", c => c.Binary());
AlterStoredProcedure(
"dbo.Department_Insert",
p => new
{
Name = p.String(maxLength: 50, unicode: false, storeType: "nvarchar"),
Budget = p.Decimal(),
StartDate = p.DateTime(),
InstructorID = p.Int(),
RowVersion = p.Binary(),
},
body:
@"SET SESSION sql_mode='ANSI';INSERT INTO `Department`(
`Name`,
`Budget`,
`StartDate`,
`InstructorID`,
`RowVersion`) VALUES (
pName,
pBudget,
pStartDate,
pInstructorID,
pRowVersion);
SELECT
`DepartmentID`
FROM `Department`
WHERE row_count() > 0 AND `DepartmentID`=last_insert_id();"
);

MVC 5 + EF 6 + MySQL Connector/NET 6.9.6 and TIMESTAMP (2 replies)

$
0
0
Hi guys,

I have a mySql db build by someone. A table has a colum defined as nullable timestamp.

I map it to my entity as

[Column(TypeName = "timestamp")]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public DateTime? MYCOL{ get; set; }

and Migrations translate this in

AlterColumn("dbo.locusrchkin", "MYCOL", c => c.DateTime(precision: 0, storeType: "timestamp"));

Running Update-Database I receive the error "Invalid default value for 'MYCOL'" because it runs

alter table `MYTABLE` modify `MYCOL` timestamp

How con I map a nullable timestamp in my POCO entity ??? It drive me crazy!

TY.

Bind MySQL table with SQLDataSource => but VS2013 keeps “SQLServer syntax” with “[ ]” (1 reply)

$
0
0
I search to bind MySQL table in ASP.net GridView with SQLDataSource but I have a problem.

In fact Visual Studio 2013 seems to use "SQLServer syntax" with "[ ]" on tables and fiels in SQL select, update, request...


==> Do you have an idea of where the bug can come from ? It can be MySQL Connector/NET ?

Thanks for help :)

MVC Scaffolding (1 reply)

$
0
0
I'm using MVC 5 + EF 6 + MySQL Connector/NET 6.9.6 but I encountered a strange behavior: when I want to create a controller from a POCO class, I have to comment this

//[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>

then uncomment for the rest of my operations like migrations.

EF6+MYSQL WHERE Error (1 reply)

$
0
0
I'm using MVC 5 + EF 6 + MySQL Connector/NET 6.8.6,the Linq is correct without “Where<T>(whereLambda)”,Follow is the code:

public List<T> GetList<S, K>(int Top, Expression<Func<T, bool>> whereLambda, Order<T, S> orderByLambda, params Order<T, K>[] orderByLambdaParams)
{
var tempData = orderByLambda.isAsc ? db.Set<T>().OrderBy<T, S>(orderByLambda.orderByExpression) : db.Set<T>().OrderByDescending<T, S>(orderByLambda.orderByExpression);

if (orderByLambdaParams == null || orderByLambdaParams.Length == 0)
{
return tempData.
Where<T>(whereLambda).
Take<T>(Top).
AsNoTracking().
ToList();
}
else
{
foreach (Order<T, K> expression in orderByLambdaParams)
{
tempData = expression.isAsc ? tempData.ThenBy(expression.orderByExpression) : tempData.ThenByDescending(expression.orderByExpression);
}

return tempData.
Where<T>(whereLambda).
Take<T>(Top).
AsNoTracking().
ToList();
}
}

ExecuteReader: Input string was not in correct format (no replies)

$
0
0
I'm using the .Net connector and I keep getting this error:
"Input String was not in correct format"

Here is what I'm doing:

I have this query:
SELECT * FROM Orders WHERE OrderNumber = @OrdNumber

I have the proper statements set to define @OrdNumber as a parameter (of VarChar type).

So, when I run my script with @OrdNumber being 300100, it works fine, but when I try with something like 300f100, it fails giving me the error above.

I've also tried putting single quotes around @OrdNumber that that's fine, except for if a row with an order number of 300100 exists, it doesn't return any results for some reason, but when I remove the quotes and run it again with 300100 for the @OrdNumber parameter, it's fine.

Ideas on how to fix this? I need the parameter to be able accept both numbers or letters or both, and run properly (return the correct results).

Does MySQL connector for .NET work with Entity Framework? (no replies)

$
0
0
Here is simple EF based program that worked wonderfully with MS SQL server:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySQLTest;

namespace initDB
{
class Program
{
static void Main(string[] args)
{
try
{
using (var context = new Entities())
{
Console.WriteLine("Creating mote descriptors");
{
var mote1 = new moteDescriptor();
mote1.ID = "mote1";
mote1.dnsName = "mote1.cloudapp.net";
mote1.moteRefreshSecs = 20;
mote1.Active = "N";
mote1.publicPort = 2399;
mote1.lanPort = 2499;
mote1.lanAddress = "10.0.0.4";
mote1.refreshTime = DateTime.Now;
context.moteDescriptors.Add(mote1);
}
{
var mote2 = new moteDescriptor();
mote2.ID = "mote2";
mote2.dnsName = "mote2.cloudapp.net";
mote2.moteRefreshSecs = 20;
mote2.Active = "N";
mote2.publicPort = 2399;
mote2.lanPort = 2499;
mote2.lanAddress = "10.0.0.5";
mote2.refreshTime = DateTime.Now;
context.moteDescriptors.Add(mote2);
}
context.SaveChanges();
Console.WriteLine("Creating mote descriptors successful");
Console.WriteLine("Success!!!");
}
}
catch (Exception ex)
{
String exceptionString = "";
for (Exception ex1 = ex; ex1 != null; ex1 = ex1.InnerException)
{
exceptionString = exceptionString + ex1.Message;
}
Console.WriteLine("Exception: {0}", ex);
}
}
}
}

With MySQL it doesn't work. The exception is thrown:
Creating mote descriptors
Exception: System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> MySql.Data.MySqlClient.MySqlException:
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 '(SELECT
`moteDescriptors`.`ID`,
`moteDescriptors`.`dnsName`,
`moteDescriptors`' at line 1
в MySql.Data.MySqlClient.MySqlStream.ReadPacket() в d:\Projects\odesk\fruitman\code\mysql-connector-net-6.9.6-src\Source\MySql.Data\MySqlStream.cs:строка 163

в MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)

The SQL statement must be generated by MySQL entityframework provider. It seems to be incorrect.

So, the question: can I use the Entity Framework with MySQL or not?

The EF connector is 6.9.6. The EntityFramework is 6.0, but I tried with 5.0 with the same result.

Have a weird problem (no replies)

$
0
0
This is my code

Private Sub btnTestConn_Click(sender As System.Object, e As System.EventArgs) Handles btnTestConn.Click
Using Mycon As New MySqlConnection
Try
Dim C As String = String.Format("Server={0};Database={1};Uid={2};Pwd={3};Port={4};Pooling=True;ConnectionReset=True;", Me.Server, Me.dDatabase, Me.USername, Me.password, Me.txtPort.Text)
Mycon.ConnectionString = C
Mycon.Open()
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
General.ShowSuccessMsg(FileResources.GetString("ECVerifyMe.ConnOK"))
End Using
End Sub

it make a crash to my application on the mycon.open()
previously the same connction open's perfectly,

what the weird this it is not even handled by the catch it crash my application

after some analysis i went to the event log viewer it show me the some info but error on mswsock.dll

any guidance will help me

MySql Connector issues (no replies)

$
0
0
So, I'm working with a project that was originally written for MS-Sql Server using Entity Framework and I'm having a number of issues with the connector. I have no objections to grabbing the source files and rebuilding and intend to dig through the source for a solution anyways as these are fairly large issues. The database I'm working with contains Approximately 130 Tables with multiple tables having more than 1M rows. It is optimized to 3rd normal with only slight deviations for the purposes of indexing.

The first issue I have had with the connector regards to deep joins in a greedy loading environment (greedy loading is very important as this is an e-commerce solution)

var pfs = tackle.ProductFamilies
.Include("Categories")
.Include("ProductImages")
.Include("ProductFamilySections")
.Include("ProductFamilyViews")
.Include("ProductFamilyVideos")
.Include("Discount_ProductFamily.Discount.Discount_ProductFamily.ProductFamily")
.Include("RelatedProductFamilies.ToFamily.Discount_ProductFamily.Discount")
.Include("RelatedFromProductFamilies.FromFamily")
.Include("Reviews.ReviewTags")
.Include("Reviews.Shopper")
.Include("Questions.Shopper") // submitted by
.Include("Questions.Shoppers") // followers
.Include("Products.ComboElements.ProductPiece.ProductFamily")
.Include("Products.ComboParents.ProductParent.ProductFamily.Discount_ProductFamily.Discount")
.Include("Products.AttributeValues.Attribute")
.Include("Products.ProductImage")
.Where(p => p.ProductFamily_DisplayURL == pfURL).ToList();

This statement will fail giving the following error

Exception
Source: System.Web
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Stack Trace: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.catalog_product_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\tackleshopnet\0acf046a\fbcfed4\App_Web_3j0nwrh5.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Inner Exception
Source: EntityFramework
Message: An error occurred while preparing the command definition. See the inner exception for details.

Stack Trace: at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory) at System.Data.Entity.Core.EntityClient.Internal.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree, DbInterceptionContext interceptionContext) at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.CreateCommandDefinition(ObjectContext context, DbQueryCommandTree tree) at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Boolean streaming, Span span, IEnumerable`1 compiledQueryParameters, AliasGenerator aliasGenerator) at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.b__6() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.b__5() at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery`1..GetEnumerator>b__0() at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at Catalog_Product.get_Fam() in c:\inetpub\wwwroot\MySql------.com\TackleshopNet\Catalog\Product.aspx.cs:line 47 at ASP.catalog_product_aspx.__RenderContent1(HtmlTextWriter __w, Control parameterContainer) in c:\inetpub\wwwroot\MySql------.com\TackleshopNet\Catalog\Product.aspx:line 6 at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at ASP.masterpage_master.__RenderHead1(HtmlTextWriter __w, Control parameterContainer) in c:\inetpub\wwwroot\MySql------.com\TackleshopNet\MasterPage.master:line 26 at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at ASP.masterpage_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\tackleshopnet\0acf046a\fbcfed4\App_Web_amerpfpm.0.cs:line 0 at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Page.Render(HtmlTextWriter writer) at FrontEndPage.Render(HtmlTextWriter writer) in c:\inetpub\wwwroot\MySql------.com\TackleshopNet\App_Code\PageClasses.cs:line 213 at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Inner Exception
Source: MySql.Data.Entity.EF6
Message: The method or operation is not implemented.
Stack Trace: at MySql.Data.Entity.SelectGenerator.Visit(DbApplyExpression expression) at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.Visit(DbUnionAllExpression expression) at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.Visit(DbSortExpression expression) at MySql.Data.Entity.SqlGenerator.VisitInputExpression(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.VisitInputExpressionEnsureSelect(DbExpression e, String name, TypeUsage type) at MySql.Data.Entity.SelectGenerator.Visit(DbProjectExpression expression) at MySql.Data.Entity.SelectGenerator.GenerateSQL(DbCommandTree tree) at MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory)





the second issue also regards greedy loading. When I attempt any joins using MySql Cluster the entire thing freezes up and I suspect that it has to do with the method used for the join. I remember seeing somewhere that the connect joins to a select statement. I need to know where I can change the Sql Generation so that I can change it to do a straight join since the select causes 2 bottlenecks. 1: it forces a read of the whole table, and 2: it changes what should be an index operation into a scan operation. This makes the join method used completely useless in a cluster environment.

EF6 / MySql Net Connector (no replies)

$
0
0
- NET Framework 4.5.2
- Entity Framework 6.1.3
- MySql.Data 6.9.7
- MySql.Data.Entity 6.9.7


On the Index page of a site, I use the above code with Microsoft SQL Server, Microsoft SQL Server Compact, Firebird, PostgreSQL and SQLite with no erros. Only I need to do is to change the ConnectionString and everything works fine:

...
Dim q As Double = 0D
Using d As New MyContext
q = d.Products.Count
End Using
...

When I try to use the same code with MySql, I've the error message: "The sequence contains no matching elements".

How to fix it ?

All the code is:

Imports System
Imports System.Data
Imports System.Data.Entity
Imports System.Data.Entity.Core
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
Imports System.ComponentModel.DataAnnotations.Schema

Public Class MyContext
Inherits DbContext

Public Overridable Property Products As DbSet(Of Product)
Public Overridable Property ProductEntryItems As DbSet(Of ProductEntryItem)
Public Overridable Property ProductEntries As DbSet(Of ProductEntry)
Public Overridable Property Phones As DbSet(Of Phone)
Public Overridable Property Supliers As DbSet(Of Suplier)

Public Sub New()
MyBase.New(MyContext.Cs)
End Sub

Private Shared Function Cs() As String
Database.SetInitializer(Of DContext)(New DropCreateDatabaseIfModelChanges(Of MyContext))
Return "eics"
End Function

Protected Overrides Sub OnModelCreating(modelBuilder As DbModelBuilder)
MyBase.OnModelCreating(modelBuilder)
End Sub
End Class

Public Enum SalesSections
<Display(Name:="General")>
<Description("Generic Pocket Products")>
[General] = 10
<Display(Name:="Butchery")>
<Description("Butchery Related Products")>
[Butchery] = 20
<Display(Name:="Backery")>
<Description("Backery Related Products")>
[Backery] = 30
<Display(Name:="Fish and Sea Food")>
<Description("Fish and Sea Food Related Products")>
[Fishmonger] = 40
<Display(Name:="Fruits, Vegetables and Greens")>
<Description("Greens Related Products")>
[Greenery] = 50
<Display(Name:="Poultry And Eggs")>
<Description("Poultry And Eggs Related Products")>
[Poultry] = 60
<Display(Name:="Home Cleanning Items")>
<Description("Home Cleanning Items Related Products")>
[HomeCleaning] = 70
<Display(Name:="Personal Hygiene")>
<Description("Personal Hygiene Related Products")>
[PersonalHygiene] = 80
<Display(Name:="Bed, Bath and Kitchen")>
<Description("Bed, Bath and Kitchen Related Products")>
[BedAndBath] = 90
End Enum
<Table("mdl103_t0012")>
Public Class Product
<Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)>
Public Property ProductId As Integer
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=1)>
<StringLength(160, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukProductName", IsUnique:=True)>
<Display(Name:="Product's Full Name")>
Public Property Name As String
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=2)>
<StringLength(118, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukProductNCM")>
Public Property NCMCode As String
<EnumDataType(GetType(SalesSections), ErrorMEssage:="Please select a section.")>
Public Property Section As SalesSections = SalesSections.General
End Class
<Table("mdl103_t0002")>
Public Class Suplier
<Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)>
Public Property SuplierId As Integer
<Display(Name:="Name")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=1)>
<StringLength(160, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukProductName", IsUnique:=True)>
Public Property Name As String
<Display(Name:="Nick Name")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=2)>
<StringLength(118, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukProductNCM")>
Public Property NickName As String
<Display(Name:="TIN")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=3)>
<StringLength(30, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukProductTIN")>
Public Property TIN As String
<Display(Name:="Phone List")>
Public Overridable Property Phones As ICollection(Of Phone) = New HashSet(Of Phone)
End Class
<Table("mdl103_t0005")>
Public Class Phone
<Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)>
Public Property PhoneId As Integer
<Display(Name:="Phone Number")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=1)>
<StringLength(160, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukPhoneNumber", IsUnique:=True)>
Public Property Number As String
<Display(AutoGenerateField:=True, AutoGenerateFilter:=True, Name:="Regional Area Code")>
<DisplayFormat(ApplyFormatInEditMode:=True, ConvertEmptyStringToNull:=True, DataFormatString:="{0:(00)}")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=2)>
<StringLength(2, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukPhoneArea")>
Public Property Area As String
<Display(AutoGenerateField:=True, AutoGenerateFilter:=True, Name:="International Area Code")>
<DisplayFormat(ApplyFormatInEditMode:=True, ConvertEmptyStringToNull:=True, DataFormatString:="{0:(00)}")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=3)>
<StringLength(2, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukPhoneCountry")>
Public Property Country As String
<Display(Name:="Operator")>
<Required(ErrorMessage:="The field {0} is required.")>
<Column(TypeName:="varchar", Order:=4)>
<StringLength(50, ErrorMessage:="The {0} field must have no more than {1} characters.")>
<Index("ukPhoneOperator")>
Public Property CompanyName As String
End Class
<Table("mdl103_t0104")>
Public Class ProductEntry
<Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)>
Public Property EntryId As Integer
<ScaffoldColumn(False)>
Public Property SuplierId As Integer
<Required(ErrorMessage:="Please, select the {0}.")>
<Display(Name:="Suplier")>
<ForeignKey("SuplierId")>
Public Overridable Property Suplier As Suplier
Public Property Received As Date
End Class
<Table("mdl103_t0105")>
Public Class ProductEntryItem
<Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)>
Public Property Id As Integer
<ScaffoldColumn(False)>
<Required>
Public Property EntryId As Integer
<ForeignKey("EntryId")>
Public Overridable Property Entry As ProductEntry
<ScaffoldColumn(False)>
<Required>
Public Property ProductId As Integer
<Display(Name:="Product")>
<ForeignKey("ProductId")>
Public Property Product As Product
<Display(Name:="Quantity")>
<Required(ErrorMessage:="{0} is required.")>
<Range(1, 2000, ErrorMessage:="{0} must be between {2} and {1}.")>
Public Property Quantity As Double = 0D
<Display(Name:="Price (by unit)")>
<Required(ErrorMessage:="{0} is required.")>
<Range(0.01D, 20000D, ErrorMessage:="{0} must be between {2} and {1}.")>
Public Property UniquePrice As Double = 0D
End Class
Viewing all 1447 articles
Browse latest View live


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