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

How can i connect my mobile App with mysql database (no replies)

$
0
0
I have a Mobile app, in which i want to list some data from mysql database which is already there. I am using a third party tool(DXtreme) to develop the app. When i contacted them they told me their tool will not support mysql directly. They given me some idea, but i dont get what they mean, because i am a beginner. They told "create your own data service that manipulate data using mysql. you can connect your application to your service using DataSource or oDataContenxt.Please note that ODataContent is intended only for an OData service". Please help me how can i do it ???

Could not load file or assembly MySql.Data.dll 0x80131515 (3 replies)

$
0
0
Hello,

I have written a PowerShell script to connect to a MySQL database to query for some information. I am using the extracted MySQL.data.dll and the script works fine, if .NET Framework 4.5 is installed. If the machine only has .NET Framework 4.0 installed, I get the below error.

add-type : Could not load file or assembly 'file:///P:\MySql.Data.dll' or
one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At P:\printer.ps1:75 char:5
+ add-type -Path "$PWD/MySql.Data.dll"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

The target environment is Win7 x64. I have been searching online for the last few days and found no reference that .NET Framework 4.5 was required. I am using PowerShell 3.0 but I would have thought one of the other .dlls would have worked. I have tried using the v2.0, v4.0, and v4.5 dlls to no avail. See below for the entire script.

[environment]::CurrentDirectory = Get-Location -PSProvider FileSystem
write-host "Changing directory to:"([environment]::currentdirectory) -ForegroundColor Yellow

function global:PrinterList {
Param(
[string]$printerip
)

$mysqlserver = "server"
$mysqldb = "db"
$mysqluser = "user"
$mysqlpassword = 'pass'
$mysqlconnectionstring = "Server=$mysqlserver; Database=$mysqldb; User=$mysqluser; Password=$mysqlpassword"

$mysqlquery = "
SELECT Model,IP,Building,Floor,Printer_ID
FROM printers
WHERE ip = '$printerip'"

#[void][System.Reflection.Assembly]::LoadFrom(".\MySql.Data.dll")
add-type -Path ".\MySql.Data.dll"

$connection = New-Object MySql.Data.MySqlClient.MySqlConnection
$connection.ConnectionString = $mysqlconnectionString
$connection.Open()
$command = New-Object MySql.Data.MySqlClient.MySqlCommand($mysqlquery, $connection)
$dataAdapter = New-Object MySql.Data.MySqlClient.MySqlDataAdapter($command)
$global:mysqltable = New-Object System.Data.DataTable
$recordCount = $dataAdapter.Fill($mysqltable)
$global:mysqltable
}

Any ideas? Is installing .NET Framework 4.5 my only option?

MySQL Connector/Net 6.6.6 has been released (no replies)

$
0
0
Dear MySQL users,

MySQL Connector/Net 6.6.6, a new version of the all-managed .NET driver for MySQL has been released. This is a maintenance release for 6.6.x.
This release is feature complete. It is recommended for use in production environments.
It is appropriate for use with MySQL server versions 5.0-5.6

It is now available in source and binary form from http://dev.mysql.com/downloads/connector/net/#downloads and mirror sites (note that not all mirror sites may be up to date at this point-if you can't find this version on some mirror, please try again later or choose another download site.)

The 6.6.6 version of MySQL Connector/Net brings the following fixes:

- Fix for GetSchema returning MySqlException instead of ArgumentException when passing an invalid collection name (Oracle bug #16271425, MySql bug #67901).
- Fix for EF 4.3 failing when FK identifiers are too long (MySql bug #67285, Oracle bug #16286397).
- Fix for race condition on ConnectionStringBuilder when using multiple threads
(MySql bug #68217, Oracle bug #16310698).
- Fix for stored routines being edited from Server explorer appear as ALTER, which may led
to syntax errors, which may led to Intellisense to stop working (Oracle bug #16357595).
- Fix for Error in Server Explorer when refreshing a table or view (Oracle bug #16363908).
- Fix for Intellisense not available for Views (Oracle bug #16384218).
- Fix for "When saving a new stored procedure, it raises a windows error message", due to
using definer (Oracle bug #16363828).
- Fix for "The first time a new stored routine is saved, after save, Intellisense doesn't work (Oracle bug #16384238).
- Fix for "Error when saving after changing an existing stored routine name in SQL in the editor" (Oracle bug #16390757).
- Fix for server explorer error opening a remote connection (Oracle bug #16357786).
- Fix for password expiration, new password dialog failed (Oracle bug #16357752).
- Fix for Specifying delete cascade in EF migrations does not work (MySql bug #68457, Oracle bug #16398432).
- Fix for InvalidCastException thrown when executing an stored function (MySql bug #64633, Oracle bug #13864627).
- Fix for Default Command Timeout not applying for EFMySqlCommand (MySql bug #67171, Oracle bug #14825670).
- Fix for Debugger cannot debug stored procedures with a main begin labeled and declare statements included (Oracle bug #16002371).
- Fix for bug If using repair option, then vs2010 doesnt allow to connect to db (Oracle bug #16238242).
- Fix for bug "Can't change the name for a view in view editor" (Oracle bug #13805346).
- Fix for "Cannot change the name for a Foreign Key in table designer" (Oracle bug #16238068).
- Fix for error when trying to set primary key for a column with same name as mysql keyword (like INT) in table designer
(Oracle bug #16238102).
- Fix for databases not displayed in connect dialog for mysql script when correcting credentials, after entering a bad password
(Oracle bug #13805337).
- Fix for Debugger fails trying to debug a stored routine in a MySql server hosted in linux without lower_case_table_names option enabled
(MySql bug #69065, Oracle bug #16770384).
- Fix for Debugger issue, Values through watch tab shouldn't allow to be modified (Oracle bug #14545448).
- Fix for Visual Studio Mysql editor colors cannot be customized (Oracle bug #16453324, MySql bug #67994).
- Fix for Parser fails to recognizes a complex view (Oracle bug #16815427).
- Fix for Altering table's primary key in designer not working (Oracle bug #16866053).
- Fix for Connector/NET cannot read data from a MySql table using UTF-16/UTF-32 (MySql bug #69169, Oracle bug #16776818).
- Fix for Entity Framework when inserts data having Identity columns (Oracle bug #16494585).
- Fix for Malformed query in Entity Framework when eager loading due to multiple projections (MySql bug #67183, Oracle bug #16872852).
- Fix for Migrations in Entity Framework when tries to update database that is already updated (Oracle bug #16869202, MySql bug#68889).
- Fix for bug IIS application pool reset worker process causes website to crash (Oracle bug #16909237, Mysql Bug #67665).
- Fix for intellisense completion, now Views are displayed together with Tables calling intellisense (Oracle Bug #16881451).
- Fix for parser syntax, now the parser supports the clause ALTER TABLE table_name RENAME {INDEX|KEY} old_index_name TO new_index_name introduced in MySql 5.7. (Oracle Bug #16881481)
- Fix for bug Error in LINQ to Entities query when using Distinct().Count() (MySql Bug #68513, Oracle bug #16950146).
- Fix for occasionally return no data when socket connection is slow, interrupted or delayed (MySql bug #69039, Oracle bug #16950212).
- Fix for ConstraintException when filling a datatable (MySql bug #65065, Oracle bug #16952323).
- Fix for Debugging a routine produces an error when binary log is enabled (Oracle bug #16941181).
- Fix for nested sql generated for LINQ to Entities query with Take and Order by (MySql bug #65723, Oracle bug #16973939).
- Several fixes for the parser:
a) Added a all server supported keywords as identifiers to grammar.
b) Solved some inconsistencies on they way begin (work) vs begin (block) was interpreted regarding server.
c) Added to grammar missing comparison operators for 'handler table read'.
d) Corrected several errors (instead of returning "missing EndOfFile" now returns "No viable alternative at input ...")/
e) Added to grammar missing support for 'show count(*) warnings'.
f) Fixed bug when case expression was accepting 'case end' (must only accept 'end').
g) Added support for '$' in identifiers.
h) Corrected some bugs in escape sequences (like not recognizing \b).
i) Fixed a bug where not all session var references were recognized (@@session.var).
j) Fixed some errors with aggregate functions (like not supporting ALL and DISTINCT).
k) Added support for 'show full tables'.
l) Corrected some inconsistencias with 'character set' clause among grammar statements.
m) Corrected bad support for casting expressions
n) Added support for missing expressions 'default' and 'values'.
o) Added optional support for condition in 'case' expression.
p) Made definition for column definition in DDLs more compliant with server.
q) Added missing support for bool/boolean data types.
r) Corrected some inconsistencies in collate for expressions.
s) Added support for ws_nsweights & opt_ws_levels in weigth function.
t) Corrected many arguments for functions with special syntax (like now being able to accept expressions instead of only literals).
u) Removed some false keywords (engine names like myisam) from lexer spec.
v) Added 200+ extra unit tests.
- Fix for bad query when using LINQ to Entities with a query using Take, OrderBy & Contains in Code First (MySql bug #69751, Oracle bug #17194945).
- Fix for Visual Studio parser for MySql does not recognize properly all valid identifiers (Oracle Bug #16881354).
- Fix for LINQ to Entities error for bad aliasing in column for expression (MySql bug #69922, Oracle bug #17285548).
- Fix for In stored routine debugger, after a case else a begin-end is badly instrumented (Oracle bug #17284598).


The release is available to download
at http://dev.mysql.com/downloads/connector/net/6.6.html

Documentation
-------------------------------------
You can view current Connector/Net documentation at http://dev.mysql.com/doc/refman/5.5/en/connector-net.html


You can find our team blog at http://blogs.oracle.com/MySQLOnWindows
You can also post questions on our forums at http://forums.mysql.com/

Enjoy and thanks for the support!

Connector/NET Team

How to do Insert in many-to-many scenario while working with entity framework for mysql? (no replies)

$
0
0
This should be a quite common scenario. Here're the database tables.

CREATE TABLE table1 ( ID int(11) NOT NULL AUTO_INCREMENT, Name varchar(45) DEFAULT NULL, PRIMARY KEY (ID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE table2 ( ID int(11) NOT NULL AUTO_INCREMENT, Name varchar(45) DEFAULT NULL, PRIMARY KEY (ID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE table1_table2 ( ID1 int(11) NOT NULL, ID2 int(11) NOT NULL, KEY fk1_idx (ID1), KEY fk2_idx (ID2), CONSTRAINT fk1 FOREIGN KEY (ID1) REFERENCES table1 (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk2 FOREIGN KEY (ID2) REFERENCES table2 (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8

Then here's my Program.cs:

static void Main(string[] args)
{
using (testEntities ctx = new testEntities())
{
table1 t1 = new table1
{
Name = "t1",
table2 = new List<table2>()
};

table2 t2 = new table2
{
Name = "t2"
};

t1.table2.Add(t2);
ctx.table1.Add(t1);

ctx.SaveChanges();
}
}

Quite straightforward snippet. Then I got this annoying exception:

An error occurred while saving entities that do not expose foreign key properties for their relationships. The EntityEntries property will return null because a single entity cannot be identified as the source of the exception. Handling of exceptions while saving can be made easier by exposing foreign key properties in your entity types. See the InnerException for details.

A little drill-down got me to some weird sql syntax error:

{"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\n `table1_table2`.`ID1`, \n `table1_table2`.`ID2`\n FROM `ta' at line 1"}

Have no idea where in this auto-generated sql has syntax error.

Any clue to help me please? Thanks.
Nico

MySQL Connector/Net 6.5.7 has been released (no replies)

$
0
0
Dear MySQL users,

MySQL Connector/Net 6.5.7, a new version of the all-managed .NET driver for MySQL has been released. This is a maintenance release for 6.5.x.
This release is feature complete. It is recommended for use in production environments.
It is appropriate for use with MySQL server versions 5.0-5.6

It is now available in source and binary form from http://dev.mysql.com/downloads/connector/net/#downloads and mirror sites (note that not all mirror sites may be up to date at this point-if you can't find this version on some mirror, please try again later or choose another download site.)

The 6.5.7 version of MySQL Connector/Net brings the following fixes:

- Fix for bug If using repair option, then vs2010 doesnt allow to connect to db (Oracle bug #16238242).
- Fix for bug "Can't change the name for a view in view editor" (Oracle bug #13805346).
- Fix for "Cannot change the name for a Foreign Key in table designer" (Oracle bug #16238068).
- Fix for error when trying to set primary key for a column with same name as mysql keyword (like INT) in table designer
(Oracle bug #16238102).
- Fix for databases not displayed in connect dialog for mysql script when correcting credentials, after entering a bad password
(Oracle bug #13805337).
- Fix for Visual Studio Mysql editor colors cannot be customized (Oracle bug #16453324, MySql bug #67994).
- Fix for Parser fails to recognizes a complex view (Oracle bug #16815427).
- Fix for Altering table's primary key in designer not working (Oracle bug #16866053).
- Fix for Connector/NET cannot read data from a MySql table using UTF-16/UTF-32 (MySql bug #69169, Oracle bug #16776818).
- Fix for Entity Framework when inserts data having Identity columns (Oracle bug #16494585).
- Fix for Malformed query in Entity Framework when eager loading due to multiple projections (MySql bug #67183, Oracle bug #16872852).
- Fix for bug IIS application pool reset worker process causes website to crash (Oracle bug #16909237, Mysql Bug #67665).
- Fix for intellisense completion, now Views are displayed together with Tables calling intellisense (Oracle Bug #16881451).
- Fix for bug Error in LINQ to Entities query when using Distinct().Count() (MySql Bug #68513, Oracle bug #16950146).
- Fix for occasionally return no data when socket connection is slow, interrupted or delayed (MySql bug #69039, Oracle bug #16950212).
- Fix for ConstraintException when filling a datatable (MySql bug #65065, Oracle bug #16952323).
- Fix for nested sql generated for LINQ to Entities query with Take and Order by (MySql bug #65723, Oracle bug #16973939).
- Several fixes for the parser:
a) Added a all server supported keywords as identifiers to grammar.
b) Solved some inconsistencies on they way begin (work) vs begin (block) was interpreted regarding server.
c) Added to grammar missing comparison operators for 'handler table read'.
d) Corrected several errors (instead of returning "missing EndOfFile" now returns "No viable alternative at input ...")/
e) Added to grammar missing support for 'show count(*) warnings'.
f) Fixed bug when case expression was accepting 'case end' (must only accept 'end').
g) Added support for '$' in identifiers.
h) Corrected some bugs in escape sequences (like not recognizing \b).
i) Fixed a bug where not all session var references were recognized (@@session.var).
j) Fixed some errors with aggregate functions (like not supporting ALL and DISTINCT).
k) Added support for 'show full tables'.
l) Corrected some inconsistencias with 'character set' clause among grammar statements.
m) Corrected bad support for casting expressions
n) Added support for missing expressions 'default' and 'values'.
o) Added optional support for condition in 'case' expression.
p) Made definition for column definition in DDLs more compliant with server.
q) Added missing support for bool/boolean data types.
r) Corrected some inconsistencies in collate for expressions.
s) Added support for ws_nsweights & opt_ws_levels in weigth function.
t) Corrected many arguments for functions with special syntax (like now being able to accept expressions instead of only literals).
u) Removed some false keywords (engine names like myisam) from lexer spec.
v) Added 200+ extra unit tests.
- Fix for bad query when using LINQ to Entities with a query using Take, OrderBy & Contains in Code First (MySql bug #69751, Oracle bug #17194945).
- Fix for Visual Studio parser for MySql does not recognize properly all valid identifiers (Oracle Bug #16881354).
- Fix for LINQ to Entities error for bad aliasing in column for expression (MySql bug #69922, Oracle bug #17285548).
- Fix for error when creating or opening a stored procedure or function in Visual Studio Server Explorer (Oracle bug #17342436).



The release is available to download
at http://dev.mysql.com/downloads/connector/net/6.5.html

Documentation
-------------------------------------
You can view current Connector/Net documentation at http://dev.mysql.com/doc/refman/5.5/en/connector-net.html


You can find our team blog at http://blogs.oracle.com/MySQLOnWindows
You can also post questions on our forums at http://forums.mysql.com/

Enjoy and thanks for the support!

Connector/NET Team

MySql – Authentication with old password no longer supported, use 4.1 style passwords (2 replies)

$
0
0
I wrote a Visual Basic application to sell that uses the .NET connector 6.6.6 for MySQL.

About 50% of my customers get the message:
"MySql – Authentication with old password no longer supported, use 4.1 style passwords"

I have found that if TOAD for MySQL is used on the workstation that needs to connect and the following commands are run the problem is solved:

SET SESSION old_passwords=0;
SET PASSWORD=PASSWORD('YOURDATABASEPASSWORD');


The CPANEL/PHPmyAdmin the users have access cannot make the change to the password and I cannot run the commands remote and make it work for my users.

This means that 50% of my customers have to download TOAD, learn how to use it and run it on maybe 10 databases before they can use my application.


Is there another solution or workaround for this problem?

Can I add some code to the application to avoid the error in the first place?

Is this a bug or just a problem?

Entity Framework 6 support (1 reply)

$
0
0
Hi,

Hopefully we will be getting EF6 support in Connector/Net soon. Is this a goal of the Connector/Net developers?

I won't bother to ask when it will be released, but can someone please tell me the best way to get notified when Connector/Net is updated to support EF6?

Thanks

CLR20r3 Error on Windows Application using C# and MySQL NET . (no replies)

$
0
0
Hi,

I have a application which needs to runs 24/7
The application reads and writes data to MySQL
I am using C# and .net Connector (mysql-connector-net-6.6.5)
The application runs fine for few hours and suddenly gets error "CLR20r3"
some times it runs for a day and then error out and some times its withing 1 or 2 hours.

I have added Try catch to each call but as the DLL is crashing .net cannot handle that and my application is crashing.


I tried this on two machine both has same problem

Any help is appriciated.

Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: videolibrarycronjob.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 521e28b9
Problem Signature 04: MySql.Data
Problem Signature 05: 6.6.5.0
Problem Signature 06: 510943ee
Problem Signature 07: 49f
Problem Signature 08: 163
Problem Signature 09: N3CTRYE2KN3C34SGL4ZQYRBFTE4M13NB
OS Version: 6.1.7601.2.1.0.400.8
Locale ID: 1033
Additional Information 1: fbcc
Additional Information 2: fbcc0a3766b09d45f16668b808566042
Additional Information 3: 005a
Additional Information 4: 005a2571aa43772472e0fdaf9dda5208

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt

Using Cyrillic in naming database (no replies)

$
0
0
Good day!
It has long been using the Cyrillic alphabet when naming fields, the names of the tables and databases. It is not always immediately possible to connect to the database from Visual Studio. Now after reinstalling the OS and VS 2010 SP1 trying to restore (a new) connection to a database with the name "цукс". In the connection dialog when choosing a database from the drop down menu there is a base of the same name, among others. In additional settings specify utf8. However, I get a message "Auhtentication to localhost for user root using method" mysql native password "failed with message" unknown database '????' ". Uses a driver mysql-connector-net-6.6.5. If possible - any idea. Thanks in advance!

Cannot connect to MySql using Repository pattern (no replies)

$
0
0
Hi
We have got a project with multiple .Net solutions (C#) and every solution is implemented using the Repository and Unit of Work pattern. We are also using Entity Framework 5.0 as the data access technology and MS SQL as the database server. All the solutions are in visual studio 2012. Now we want migrate to MySQl server as our database server without doing much change in the design. To do this what I have done is
1. Migrated all the tables and data to MySql from Ms SQL. (We are not using any stored procedures).
2. I have installed the ADO.NET driver for MySQL which is Connector/Net 6.7.4.
3. I have added a reference to the MySql.Data.dll in the Data layer project and test project.
But every time I am trying getting the DBContext from the database I am receiving the following error:
Object reference not set to an instance of an object. at MySql.Data.MySqlClient.MySqlClientFactory.get_MySqlDbProviderServicesInstance() at MySql.Data.MySqlClient.MySqlClientFactory.System.IServiceProvider.GetService(Type serviceType) at System.Data.Common.DbProviderServices.GetProviderServices(DbProviderFactory factory) at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.Initialize() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() at System.Data.Entity.Internal.Linq.InternalSet`1.get_Local() at System.Data.Entity.DbSet`1.get_Local()"
I have also tried to add a reference MySql.Data.Entity.dll in the Dal layer project I am receiving the following error when trying to access the DBContext
“Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluation.”
I have tried to add the MySql.Web.dll and same error. And then I am not using MySql.Web.dll anymore because I could not find any reason using this anyway.
For both the dls (MySql.Data.Entity.dlland MySql.Data.dll) the Copy local property was set true. And I have checked the version of the dlls. Both of them are version 6.7.4.0. The config file had the following sections added:
<system.data>
<DbProviderFactories>
<clear />
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description="Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=6.7.4.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>

<connectionStrings>
<add name="MyDbContextName" connectionString="SERVER=aaa.bbb.ccc.ddd; DATABASE= MyDbContextDbName; UID=xxx; PASSWORD=xxxxx;" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>

To resolve the issue I have tried the following options:
1. Removed MySql.Data.Entity.dll and MySql.Data.dll from the data layer projects, got the same dlls using the Nuget Package, and cleaned the solution but the same behaviour as above.
2. I have applied the steps mentioned in the following link http://www.jeffscorner.org/blog/category/MySQL.aspx. But the same result.
3. I have applied the steps mentioned in the following link http://stackoverflow.com/questions/14582751/mysql-connector-always-get-object-reference-not-set-to-an-instance-of-an-object. But the same result.
Our code is using the following pattern
public class MyBaseContext<T> : DbContext where T : DbContext
{

static MyBaseContext ()
{
Database.SetInitializer<T>(null);
}

protected MyBaseContext ()
: base("name=MyDbContextName")
{
}

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Entity<MyEntity>().ToTable("MyEntity");
}

}

[Table("MyEntity")]
public class MyEntity
{
[Key]
public string Id { get; set; }

[ConcurrencyCheck]
public int NextSeed { get; set; }
}

public class MyContext : MyBaseContext <MyContext>
{
public DbSet<MyEntity> MyEntities { get; set; }
}

public interface IMyRepository
{
MyEntity FindById(int Id);
void Commit();
}
public class MyRepository : IMyRepository
{
MyContext context{get;set;}

public MyRepository ()
{
context = new MyContext ();
}

#region IMyRepository Members

public MyEntity FindById (int Id)
{
return context.MyEntities
.FirstOrDefault(x => x.Id == Id);
}

public void Commit()
{
context.SaveChanges();
}

#endregion
}

Any kind of help would be much appreciated.
Thanks & Regards,
Silvi

Going from bad to worse (1 reply)

$
0
0
I am trying to make MySQL work with ASP.NET (VS 2012 Web edition). I downloaded the MySql Workbench (community edition); created a table in one of the default dbs and can successfully query the table. So I know that works to some extent. Now I'm trying to create an ODBC connection. So I downloaded the 5.2 ANSI Drive (64-bit). But that didn't work. I put this into my webconfig file:

<connectionStrings>
<add name="MySQLConnStr" connectionString="{DRIVER=MySql ODBC 5.2 ANSI Driver};Database=world;Server=MySQL10;UID=XX;PWD=XXXXXX;"/>
</connectionStrings>

I get Datasource name not found; no drive specified.


I'm using the 32-bit driver.

From the Workbench, things look OK (to my untrained eye).

I've looked at ConnectionStrings.com but that doesn't seem to make a difference.

******************
NOT SURE WHAT HAPPENED: I moved the connection string data from the webconfig.xml to the app itself and, magically, it worked.


RON

asp.net session state sql script (no replies)

$
0
0
My Connector for .Net is not working. It keeps crashing so I am not able to create the MySql session state tables and configurations for my web application project.

It's a asp.net 4.5 mvc application project.

Could anyone please post the sql for creating the session tables to use the mysql session state provider?


Thanks,

Jack

Disabling Guids from CHAR(36) columns? (no replies)

$
0
0
We have a SugarCRM system that we inherited. I am trying to talk to the MySQL database via a .NET MVC4 app using either Entity Framework or ADO.NET.

The problem I am running into is who ever did the initial SugarCRM install initially had it setup to use integer IDs before switching over to GUIDs.

While a majority of the keys I run across are standard GUIDs, others are "1", "2", or even "" instead of NULL.

Since SugarCRM is so large, I don't want to change a key and track down all of the places it is referenced that also have to be changed.

Is there a way to stop Connector/NET from recognizing CHAR(36) as GUID?
I've tried to override by changing the entity properties it created to string, however that just throws compile time errors stating I have a mismatch.

Cannot Install Connector Net 6.7.4 (1 reply)

$
0
0
Hello,

I am unable to install the Connector 6.7.4 package. The installer just exits with a generic error message.
I am running Windows 7 on a 64 bit machine.
I have the log and can supply it if required.
Any thoughts?

Thanks,

RP

Invalid attempt to access a field before calling Read() (no replies)

$
0
0
We are getting the below exception randomly in serveral places. Any pointers?

2013-09-23 23:10:02,265 [112] ERROR ExceptionLogger - ChangePassword
System.Configuration.Provider.ProviderException: An exception occurred. Please check the Event Log. ---> MySql.Data.MySqlClient.MySqlException: Invalid attempt to access a field before calling Read()
at MySql.Data.MySqlClient.ResultSet.get_Item(Int32 index)
at MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue(Int32 index, Boolean checkNull)
at MySql.Data.MySqlClient.MySqlDataReader.GetString(Int32 i)
at MySql.Web.Security.MySQLMembershipProvider.GetPasswordInfo(MySqlConnection connection, Int32 userId, String& passwordKey, MembershipPasswordFormat& passwordFormat)
at MySql.Web.Security.MySQLMembershipProvider.ChangePassword(String username, String oldPassword, String newPassword)
--- End of inner exception stack trace ---
at MySql.Web.Security.MySQLMembershipProvider.ChangePassword(String username, String oldPassword, String newPassword)

unable to connect to any of the specified mysql hosts (2 replies)

$
0
0
Hi,

I am having trouble with a process in my software application as it relates to maintaining a connection. I have a process that loops through each policy record in my database doing various data updates for each record. Randomly I will get an "unable to connect to any of the specified mysql hosts" error when doing one of those updates.

I only get this error when I run the process on my client's server. When I run the process locally on my machine within the Visual Studio IDE I do not get this error and everything is just fine.

I will point out that my client is currently running this process against another MySQL database in the same MySQL instance without any issues so I'm not sure why I'm getting this error.

I am using VB.NET and ADO.Net driver for MySQL version 6.5.4.0. My connection string is also like this "Database=xxxxx;Data Source=localhost;Port=3306;User Id=xxx;password=xxx;pooling=false;"

Thanks.

Problem of SQL parameters (2 replies)

$
0
0
Hello everybody,
As I needed to know my user id to insert it in another table, I inserted this code in MySqlMembershipProvider.cs
Well, I should like to know why it works only if I replace parameters explicitly by their values, while this is supposedly automatic.
Another question could concern how to call it : MySqlMembershipProvider has public values, but the user is initialised in it when signing on, and then is released. After that you have to provide connection and parameters again. Anything I did not see ?

public string GetUserKey(string Username, string ApplicationName, string connectionString)
{
string strPKID = "";
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
MySqlCommand cmd = new MySqlCommand("SELECT PKID, Username, Email, PasswordQuestion," +
" Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate," +
" LastActivityDate, LastPasswordChangedDate, LastLockedOutDate" +
" FROM `" + tableName + "` WHERE Username = ?Username AND ApplicationName = ?ApplicationName", conn);

cmd.Parameters.Add("?Username", MySqlDbType.VarChar, 255).Value = Username;
cmd.Parameters.Add("?ApplicationName", MySqlDbType.VarChar, 255).Value = ApplicationName;

conn.Open();
cmd.CommandText = cmd.CommandText.Replace("?Username", "'" + cmd.Parameters["?Username"].Value.ToString() + "'").Replace("?ApplicationName", "'" + cmd.Parameters["?ApplicationName"].Value.ToString() + "'");
using (MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
if (reader.HasRows)
{
reader.Read();
strPKID = reader.GetString(0);
reader.Close();
}
}
}
return (strPKID);

}

unable to connect to any of the specified mysql hosts (5 replies)

$
0
0
This is a "Public Safety" application that I am attempting to migrate to Windows 7 from Windows XP.

I am getting the message: "unable to connect to any of the specified mysql hosts" from a Visual Studio 2010 C# (GUI) application on a Windows 7 (64) computer.

The app connects to the mySQL database just fine from Windows XP 32 bit.

Things I have tried on the Win7 computer:
1) installed the MySQL Connector 6.7.4 and Visual Studio 1.0.2 using the MySQL Installer
2) created a basic GUI forms VS 2010 project to only test a mySQL connection
3) tried a reference to MySQL.Data.dll version 6.7.4 for .net 4.0
4) tried a reference to MySQL.Data.dll version 6.7.4 for .net 2.0
5) tried your nifty code here( http://dev.mysql.com/doc/refman/5.6/en/connector-net-tutorials-intro.html ) in a basic console application -- it also errors out with "Unable to connect to any of the specified MySQL hosts."

... no matter what I try I always get "Unable to connect to any of the specified MySQL hosts".

Can someone provide some assistance?

MySql drivers for .NET doesn't support Polygon struct, does it? (1 reply)

$
0
0
Hello dear MySQL community!

I won't desrcribe here detailed about my problem, because your forum doesn't allow to embed images, highlighted source code etc...

So, I'll give you a link to other famous IT-comminity `Stackoverflow`, there I've described my problem and it's perfectly created to review my problem, so the link is:

http://stackoverflow.com/questions/19139884/mysql-drivers-for-net-doesnt-support-polygon-struct-does-it

PS
I have tried to post a message here with images, etc... But your forum didn't allow me to post with a message: `A word you have used in your post has been banned from use. Please use a different word or contact the forum administrators.`.

Make MySql Connector/.NET 6.7.4 use LIKE instead LOCATE with Contains? (1 reply)

$
0
0
I'm using the 6.7.4 .NET Connector for MySQL and i have a problem with a linq to sql query that uses the Contains .NET method.. i have to search the word 'movil' and in the DB there are words with 'móvil'.. with LIKE this returns results but because the .NET Connector uses LOCATE mysql function, then this function doesn't retrieve the same results.. how can i do to change this and use the LIKE function instead LOCATE?

If i run the result query in mysql the query doesn't retrieve any result, but if i only change the LOCATE function to the LIKE function, then this brings the correct results that i want
Viewing all 1447 articles
Browse latest View live


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