is it possible to take backup from Microsoft SQL Server to Mysq? directly
↧
How to take backup from Microsoft SQL Server to Mysq?l (no replies)
↧
ExecuteNonQuery() returns 0 if insert successful in both table! (no replies)
I think nothing's wrong with the connection because when I open it, it does not throw any error.
So I guess the error is when I'm executing a command through the store procedure.
From google ExecuteNonQuery() will return the row than affected during insert, update.
But my scenario will always get 0 if it is successful or not successful. Please correct me anything I'm wrong or misunderstand .
Please also suggest and the best way to achieve the result insert into two table. Thanks you
using (MySqlCommand cmd = new MySqlCommand("sp_insertlogin", sqlConn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@infristname", objsr.fristName);
cmd.Parameters.AddWithValue("@insurname", objsr.surName);
cmd.Parameters.AddWithValue("@inemailAddress", objsr.email);
cmd.Parameters.AddWithValue("@inphoneNumber", objsr.phone);
cmd.Parameters.AddWithValue("@inprofileImg", objsr.profileImg);
cmd.Parameters.AddWithValue("@inuserPass", objsr.password);
cmd.Parameters.Add(new MySqlParameter("id", MySqlDbType.Int32));
cmd.Parameters["id"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new MySqlParameter("userExits", MySqlDbType.Int32));
cmd.Parameters["userExits"].Direction = ParameterDirection.Output;
result = cmd.ExecuteNonQuery();
var outval = cmd.Parameters["@id"].Value;
var userExits = cmd.Parameters["@userExits"].Value;
if ((int)userExits == 2)
return 2;
return result;
}
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_insertlogin`(
IN infristName VARCHAR(300),
IN insurname VARCHAR(300),
IN inemailAddress VARCHAR(500),
IN inphoneNumber INT(11),
IN inprofileImg VARCHAR(300),
IN inuserPass VARCHAR(2000),
OUT id INT(11) ,
OUT userExits INT(11)
)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION rollback;
DECLARE EXIT HANDLER FOR NOT FOUND rollback;
DECLARE EXIT HANDLER FOR SQLWARNING rollback;
START TRANSACTION;
IF EXISTS (SELECT emailAddress FROM user_access.user_account where emailAddress = inemailAddress) THEN
SET userExits = 2;
SET id = 0;
ELSE
SET userExits = 0;
INSERT INTO user_access.user_account
(
fristName ,
surname ,
emailAddress ,
phoneNumber ,
profileImg
)
VALUES
(
infristname ,
insurname ,
inemailAddress ,
inphoneNumber ,
inprofileImg
);
SET id = LAST_INSERT_ID();
INSERT INTO user_access.user_profile
(
userAccount ,
password
)
VALUES
(
id ,
inuserPass
);
COMMIT;
END IF;
END
So I guess the error is when I'm executing a command through the store procedure.
From google ExecuteNonQuery() will return the row than affected during insert, update.
But my scenario will always get 0 if it is successful or not successful. Please correct me anything I'm wrong or misunderstand .
Please also suggest and the best way to achieve the result insert into two table. Thanks you
using (MySqlCommand cmd = new MySqlCommand("sp_insertlogin", sqlConn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@infristname", objsr.fristName);
cmd.Parameters.AddWithValue("@insurname", objsr.surName);
cmd.Parameters.AddWithValue("@inemailAddress", objsr.email);
cmd.Parameters.AddWithValue("@inphoneNumber", objsr.phone);
cmd.Parameters.AddWithValue("@inprofileImg", objsr.profileImg);
cmd.Parameters.AddWithValue("@inuserPass", objsr.password);
cmd.Parameters.Add(new MySqlParameter("id", MySqlDbType.Int32));
cmd.Parameters["id"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new MySqlParameter("userExits", MySqlDbType.Int32));
cmd.Parameters["userExits"].Direction = ParameterDirection.Output;
result = cmd.ExecuteNonQuery();
var outval = cmd.Parameters["@id"].Value;
var userExits = cmd.Parameters["@userExits"].Value;
if ((int)userExits == 2)
return 2;
return result;
}
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_insertlogin`(
IN infristName VARCHAR(300),
IN insurname VARCHAR(300),
IN inemailAddress VARCHAR(500),
IN inphoneNumber INT(11),
IN inprofileImg VARCHAR(300),
IN inuserPass VARCHAR(2000),
OUT id INT(11) ,
OUT userExits INT(11)
)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION rollback;
DECLARE EXIT HANDLER FOR NOT FOUND rollback;
DECLARE EXIT HANDLER FOR SQLWARNING rollback;
START TRANSACTION;
IF EXISTS (SELECT emailAddress FROM user_access.user_account where emailAddress = inemailAddress) THEN
SET userExits = 2;
SET id = 0;
ELSE
SET userExits = 0;
INSERT INTO user_access.user_account
(
fristName ,
surname ,
emailAddress ,
phoneNumber ,
profileImg
)
VALUES
(
infristname ,
insurname ,
inemailAddress ,
inphoneNumber ,
inprofileImg
);
SET id = LAST_INSERT_ID();
INSERT INTO user_access.user_profile
(
userAccount ,
password
)
VALUES
(
id ,
inuserPass
);
COMMIT;
END IF;
END
↧
↧
executereader error (1 reply)
hi, I have a vb program that wants to retrieve data from MySQL dbase.
this code is working fine :
Dim vDATE As String
vDATE = mDATE.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture)
Dim connstring As String = "server=xxx.xxx.x.xx;database=dbname;uid=idko;Pwd=passko"
Using con As New MySqlConnection(connstring)
con.Open()
Dim query As String = "SELECT issue_date, inc_date, exp_date, total FROM table_name WHERE COC_DATE = @DATE "
Dim MYSQLCMD As New MySqlCommand(query, con)
MYSQLCMD.Parameters.AddWithValue("@DATE", vDATE)
Dim reader As MySqlDataReader = MYSQLCMD.ExecuteReader
While reader.Read
MessageBox.Show(reader.GetString(0) & vbCr & reader.GetString(1) & vbCr & reader.GetString(2) & vbCr & reader.GetString(3))
End While
End Using
but the code below give me an error that says "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"
Dim vDATE As String
vDATE = mDATE.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture)
Dim connstring As String = "server=xxx.xxx.x.xx;database=dbname;uid=idko;Pwd=passko"
Using con As New MySqlConnection(connstring)
con.Open()
Dim query As String = "SELECT ref_no,name, address,zipcode FROM table_name WHERE COC_DATE = @DATE "
Dim MYSQLCMD As New MySqlCommand(query, con)
MYSQLCMD.Parameters.AddWithValue("@DATE", vDATE)
Dim reader As MySqlDataReader = MYSQLCMD.ExecuteReader
While reader.Read
MessageBox.Show(reader.GetString(0) & vbCr & reader.GetString(1) & vbCr & reader.GetString(2) & vbCr & reader.GetString(3))
End While
End Using
any help would be greatly appreciated.
thank you.
this code is working fine :
Dim vDATE As String
vDATE = mDATE.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture)
Dim connstring As String = "server=xxx.xxx.x.xx;database=dbname;uid=idko;Pwd=passko"
Using con As New MySqlConnection(connstring)
con.Open()
Dim query As String = "SELECT issue_date, inc_date, exp_date, total FROM table_name WHERE COC_DATE = @DATE "
Dim MYSQLCMD As New MySqlCommand(query, con)
MYSQLCMD.Parameters.AddWithValue("@DATE", vDATE)
Dim reader As MySqlDataReader = MYSQLCMD.ExecuteReader
While reader.Read
MessageBox.Show(reader.GetString(0) & vbCr & reader.GetString(1) & vbCr & reader.GetString(2) & vbCr & reader.GetString(3))
End While
End Using
but the code below give me an error that says "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond"
Dim vDATE As String
vDATE = mDATE.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture)
Dim connstring As String = "server=xxx.xxx.x.xx;database=dbname;uid=idko;Pwd=passko"
Using con As New MySqlConnection(connstring)
con.Open()
Dim query As String = "SELECT ref_no,name, address,zipcode FROM table_name WHERE COC_DATE = @DATE "
Dim MYSQLCMD As New MySqlCommand(query, con)
MYSQLCMD.Parameters.AddWithValue("@DATE", vDATE)
Dim reader As MySqlDataReader = MYSQLCMD.ExecuteReader
While reader.Read
MessageBox.Show(reader.GetString(0) & vbCr & reader.GetString(1) & vbCr & reader.GetString(2) & vbCr & reader.GetString(3))
End While
End Using
any help would be greatly appreciated.
thank you.
↧
Autoimport CSV Files (no replies)
Hello all.
I have this line in a VBS file, it will take a CSV and import it into a table called actions, but since moving to a new server where the MySQL is remote from I gather I need to change this VBS to use the mySQLImport command.
The MySQL server is on an IP of 192.168.0.4 Hostname is MYSQL and the CSV files and scripts are on 192.168.0.5 Hostname is MSSQL
Any ideas please?
Cheers
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim resGuid
resGuid = WScript.Arguments(0)
Dim fileName
fileName = "actions." & resGuid & "csv"
'Message fileName
Dim file
If fso.FileExists(fileName) Then
Set file = fso.OpenTextFile(fileName, 1)
'Message "have file"
Dim colLine, resLine
colLine = file.ReadLine
resLine = file.ReadLine
file.close()
Set file = Nothing
Message colLine
Message resLine
colLine = Replace(colLine, """", "")
Dim shell
Set shell = CreateObject("WScript.Shell")
Dim cmd
cmd = "C:\wamp64\bin\mysql\mysql5.7.26\bin\mysqlimport.exe --local --user=root --password=MySQL_PASSWORD actions --fields-optionally-enclosed-by=\"" --fields-terminated-by=, --ignore-lines=1 --columns=" & colLine & " --verbose " & fileName
'Message cmd
Dim cmdMinus
cmdMinus = Replace(cmd, colLine, "")
'Dim resultFields
'resultFields = Split(resLine, ",")
'Dim resGuid
'resGuid = resultFields(9)
Message resGuid
Dim output
output = RunCommandAndGetResult(cmd)
Message("Warning..")
Dim warnings
warnings = Split(output, "Warnings: ")
Message warnings(1)
Dim warningCount
warningCount = Split(warnings(1))(0)
Message warningCount
' Check whether report is in database
cmd = "C:\wamp64\bin\mysql\mysql5.7.26\bin\mysql -e ""SELECT count(*) FROM actions WHERE reportGuid = '" & resGuid & "'"" --user=root --password=MySQL_PASSWORD DATABASE_NAME"
Message cmd
Dim selectCount
selectCount = RunCommandAndGetResult(cmd)
Dim count
count = Split(selectCount, "(*)")
Message count(1)
Dim numCount
numCount = Split(count(1), vbCrLf)
Message numCount(1)
Dim archiveFolder
Message archiveFile
If numCount(1) <> "1" Then
SendAlert "Import unsuccessful", resLine
Message "Failed"
archiveFolder = "Error"
ElseIf warningCount <> "0" Then
SendAlert "Import generated warnings, but report has been imported", resLine
Message "Warning"
archiveFolder = "Warning"
Else
Message "Success"
archiveFolder = "Done"
End If
Dim archiveFile
archiveFile = "AutoImport_" & archiveFolder & "\" & fileName
If fso.FileExists(archiveFile) Then
fso.DeleteFile(archiveFile)
End If
fso.moveFile fileName, archiveFile
Set fso = Nothing
End If
Function RunCommandAndGetResult(cmd)
Dim scriptExec
'Message cmdMinus
Set scriptExec = shell.Exec(cmd)
Do While scriptExec.Status = 0
WScript.Sleep 100
Loop
Dim output
If not scriptExec.StdOut.AtEndOfStream Then
output = scriptExec.StdOut.ReadAll()
End If
Message output
RunCommandAndGetResult = output
End Function
Public Sub SendAlert(subject, body)
Set oMessage = CreateObject("CDO.Message")
oMessage.From = "ENTER EMAIL ADRRESS"
oMessage.To = "ENTER EMAIL ADDRESS"
oMessage.Subject = "ENTER SUBJECT LINE: " & subject
oMessage.Textbody = body
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ENTER MAIL SERVER"
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ENTER USERNAME"
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ENTER PASSWORD"
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = ENTER SMTP SERVER PORT
oMessage.Configuration.Fields.Update
oMessage.Send
End Sub
Public Sub Message(text)
'MsgBox text
End Sub
I have this line in a VBS file, it will take a CSV and import it into a table called actions, but since moving to a new server where the MySQL is remote from I gather I need to change this VBS to use the mySQLImport command.
The MySQL server is on an IP of 192.168.0.4 Hostname is MYSQL and the CSV files and scripts are on 192.168.0.5 Hostname is MSSQL
Any ideas please?
Cheers
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim resGuid
resGuid = WScript.Arguments(0)
Dim fileName
fileName = "actions." & resGuid & "csv"
'Message fileName
Dim file
If fso.FileExists(fileName) Then
Set file = fso.OpenTextFile(fileName, 1)
'Message "have file"
Dim colLine, resLine
colLine = file.ReadLine
resLine = file.ReadLine
file.close()
Set file = Nothing
Message colLine
Message resLine
colLine = Replace(colLine, """", "")
Dim shell
Set shell = CreateObject("WScript.Shell")
Dim cmd
cmd = "C:\wamp64\bin\mysql\mysql5.7.26\bin\mysqlimport.exe --local --user=root --password=MySQL_PASSWORD actions --fields-optionally-enclosed-by=\"" --fields-terminated-by=, --ignore-lines=1 --columns=" & colLine & " --verbose " & fileName
'Message cmd
Dim cmdMinus
cmdMinus = Replace(cmd, colLine, "")
'Dim resultFields
'resultFields = Split(resLine, ",")
'Dim resGuid
'resGuid = resultFields(9)
Message resGuid
Dim output
output = RunCommandAndGetResult(cmd)
Message("Warning..")
Dim warnings
warnings = Split(output, "Warnings: ")
Message warnings(1)
Dim warningCount
warningCount = Split(warnings(1))(0)
Message warningCount
' Check whether report is in database
cmd = "C:\wamp64\bin\mysql\mysql5.7.26\bin\mysql -e ""SELECT count(*) FROM actions WHERE reportGuid = '" & resGuid & "'"" --user=root --password=MySQL_PASSWORD DATABASE_NAME"
Message cmd
Dim selectCount
selectCount = RunCommandAndGetResult(cmd)
Dim count
count = Split(selectCount, "(*)")
Message count(1)
Dim numCount
numCount = Split(count(1), vbCrLf)
Message numCount(1)
Dim archiveFolder
Message archiveFile
If numCount(1) <> "1" Then
SendAlert "Import unsuccessful", resLine
Message "Failed"
archiveFolder = "Error"
ElseIf warningCount <> "0" Then
SendAlert "Import generated warnings, but report has been imported", resLine
Message "Warning"
archiveFolder = "Warning"
Else
Message "Success"
archiveFolder = "Done"
End If
Dim archiveFile
archiveFile = "AutoImport_" & archiveFolder & "\" & fileName
If fso.FileExists(archiveFile) Then
fso.DeleteFile(archiveFile)
End If
fso.moveFile fileName, archiveFile
Set fso = Nothing
End If
Function RunCommandAndGetResult(cmd)
Dim scriptExec
'Message cmdMinus
Set scriptExec = shell.Exec(cmd)
Do While scriptExec.Status = 0
WScript.Sleep 100
Loop
Dim output
If not scriptExec.StdOut.AtEndOfStream Then
output = scriptExec.StdOut.ReadAll()
End If
Message output
RunCommandAndGetResult = output
End Function
Public Sub SendAlert(subject, body)
Set oMessage = CreateObject("CDO.Message")
oMessage.From = "ENTER EMAIL ADRRESS"
oMessage.To = "ENTER EMAIL ADDRESS"
oMessage.Subject = "ENTER SUBJECT LINE: " & subject
oMessage.Textbody = body
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ENTER MAIL SERVER"
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ENTER USERNAME"
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ENTER PASSWORD"
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = ENTER SMTP SERVER PORT
oMessage.Configuration.Fields.Update
oMessage.Send
End Sub
Public Sub Message(text)
'MsgBox text
End Sub
↧
MySQL Connector/NET 8.0.17 has been released (no replies)
↧
↧
.NET Core on Connector/NET updates. (no replies)
↧
Working with SSH Tunneling and SSL PEM Certificates in Connector/NET (no replies)
↧
Read back Double value with no loss of digits after the decimal place (no replies)
Hi there,
I have an issue reading back a Double value from a MySQL database via the C# connector (v8.0.16).
When using MySQL Workbench (8.0.16) the value is read back correctly with no loss of digits after the decimal place - 0.00000009690000000000001
When read back using the C# connector, I cannot get the exact same value via MySqlDataReader:
reader.GetDouble - 9.6900000000000014E-08
reader.GetDecimal - 0.0000000969
How can I get the exact same value as displayed by MySql Workbench?
Regards,
Andrew
I have an issue reading back a Double value from a MySQL database via the C# connector (v8.0.16).
When using MySQL Workbench (8.0.16) the value is read back correctly with no loss of digits after the decimal place - 0.00000009690000000000001
When read back using the C# connector, I cannot get the exact same value via MySqlDataReader:
reader.GetDouble - 9.6900000000000014E-08
reader.GetDecimal - 0.0000000969
How can I get the exact same value as displayed by MySql Workbench?
Regards,
Andrew
↧
Renci.SshNet in 8.0.17 (no replies)
This error is thrown when trying to connect to a MySQL database via Power BI:
An error happened while reading data from the provider: 'Could not load file or assembly 'Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106' or one of its dependencies. The system cannot find the file specified.'
Another user mentioned this exact issue using VS2017.
An error happened while reading data from the provider: 'Could not load file or assembly 'Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106' or one of its dependencies. The system cannot find the file specified.'
Another user mentioned this exact issue using VS2017.
↧
↧
MySQL 8.0: compiling with Microsoft Visual Studio (no replies)
↧
net core 3.0 code does´t work ,in MySQL Connector/NET 8.0.18.0 (no replies)
System.TypeLoadException
HResult=0x80131522
Message=Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.18.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.
Source=MySql.Data.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.MySQLDbContextOptionsExtensions.UseMySQL(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 MySQLOptionsAction)
at WebApplication3.MySqlContext.OnConfiguring(DbContextOptionsBuilder optionsBuilder) in E:\webapitest\WebApplication3\WebApplication3\MySqlContext.cs:line 13
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.CheckState()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at WebApplication3.Controllers.DefaultController.Get() in E:\webapitest\WebApplication3\WebApplication3\Controllers\DefaultController.cs:line 19
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
HResult=0x80131522
Message=Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.18.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.
Source=MySql.Data.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.MySQLDbContextOptionsExtensions.UseMySQL(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 MySQLOptionsAction)
at WebApplication3.MySqlContext.OnConfiguring(DbContextOptionsBuilder optionsBuilder) in E:\webapitest\WebApplication3\WebApplication3\MySqlContext.cs:line 13
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.CheckState()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at WebApplication3.Controllers.DefaultController.Get() in E:\webapitest\WebApplication3\WebApplication3\Controllers\DefaultController.cs:line 19
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
↧
vs2019 webapi netcore 3.0 code does´t work ,in MySQL Connector/NET 8.0.18.0 (no replies)
vs2019 webapi netcore 3.0 code does´t work ,in MySQL Connector/NET 8.0.18.0
System.TypeLoadException
HResult=0x80131522
Message=Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.18.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.
Source=MySql.Data.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.MySQLDbContextOptionsExtensions.UseMySQL(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 MySQLOptionsAction)
at WebApplication3.MySqlContext.OnConfiguring(DbContextOptionsBuilder optionsBuilder) in E:\webapitest\WebApplication3\WebApplication3\MySqlContext.cs:line 13
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.CheckState()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at WebApplication3.Controllers.DefaultController.Get() in E:\webapitest\WebApplication3\WebApplication3\Controllers\DefaultController.cs:line 19
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
System.TypeLoadException
HResult=0x80131522
Message=Method 'get_Info' in type 'MySql.Data.EntityFrameworkCore.Infraestructure.MySQLOptionsExtension' from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.18.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an implementation.
Source=MySql.Data.EntityFrameworkCore
StackTrace:
at Microsoft.EntityFrameworkCore.MySQLDbContextOptionsExtensions.UseMySQL(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 MySQLOptionsAction)
at WebApplication3.MySqlContext.OnConfiguring(DbContextOptionsBuilder optionsBuilder) in E:\webapitest\WebApplication3\WebApplication3\MySqlContext.cs:line 13
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.CheckState()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Collections.Generic.IEnumerable<TEntity>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at WebApplication3.Controllers.DefaultController.Get() in E:\webapitest\WebApplication3\WebApplication3\Controllers\DefaultController.cs:line 19
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
↧
MySQL.Data v8.0.18 fails if more than one IP is found in DNS for a named host (no replies)
I recently updated the NuGet package for MySql.Data from 8.0.17 to 8.0.18 in one of my VB.NET (VS2017) projects. Prior to this update, I had no problem connecting to a named server which has multiple DNS entries pointing to different interfaces (and thus, IP addresses) on the same server. As soon as I updated the MySql.Data package, however, the connection started failing with the error "Unable to connect to any of the specified MySQL hosts".
My application has an error handler that logs the details of the exception to a file which it then sends to me via e-mail. Looking through the stack trace of the exception and its inner exception, I found that it seems to be doing something odd when it comes to a named host (<SERVERNAME> below). The inner exception indicates that it's returning multiple addresses to the MySqlClient.NativeDriver.Open() method, which is apparently causing it to fail.
I changed the connection properties to use a specific IP address from DNS assigned to that host, and the connection worked just fine. I also tried with other specific IP's for that host, and they all came back successful.
I'm running VS2017 on Windows 10 Pro (x64) in a domain environment. I've been able to modify my code to make a call to System.Net.Dns.GetHostEntry so that I can get a valid IP as resolved by DNS for a named host before attempting to open the connection, but that seems a bit excessive. I need to have the ability/option to pass in a simple host name and not have MySql.Data break.
Here are the (obfuscated) details gathered by my application's error handler:
------------------------------------------------------------------------
EXCEPTION DETAILS
------------------------------------------------------------------------
Error Type: MySql.Data.MySqlClient.MySqlException
Error Source: MySql.Data
Error Message: Unable to connect to any of the specified MySQL hosts.
------------------------------------------------------------------------
MYSQL DATABASE ERROR DETAILS
------------------------------------------------------------------------
Database Error: Unable to connect to any of the specified MySQL hosts.
Error Code: -2147467259
------------------------------------------------------------------------
STACK TRACE
------------------------------------------------------------------------
at MySQLDB.Open() in clsMySQL.vb:line 1175
at MySQLDB.TestConnection() in clsMySQL.vb:line 852
at ValidateUser() in DataTier.vb:line 2538
------------------------------------------------------------------------
EXCEPTION DATA
------------------------------------------------------------------------
Server Error Code: 1042
ConnectionString: server=<SERVERNAME>;port=3306;database=<DBNAME>;user id=<USERNAME>;password=<PASSWORD>
Stack Trace from MySql.Data.MySqlClient:
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at MySQLDB.Open() in clsMySQL.vb:line 1169
------------------------------------------------------------------------
INNER EXCEPTION
------------------------------------------------------------------------
Error Type: System.InvalidOperationException
Error Source: System.Core
Error Message: Sequence contains more than one matching element
Exception Level: 1
Stack Trace from Inner Exception (1):
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.NativeDriver.Open()
Please let me know if you require any additional information. Thank you.
My application has an error handler that logs the details of the exception to a file which it then sends to me via e-mail. Looking through the stack trace of the exception and its inner exception, I found that it seems to be doing something odd when it comes to a named host (<SERVERNAME> below). The inner exception indicates that it's returning multiple addresses to the MySqlClient.NativeDriver.Open() method, which is apparently causing it to fail.
I changed the connection properties to use a specific IP address from DNS assigned to that host, and the connection worked just fine. I also tried with other specific IP's for that host, and they all came back successful.
I'm running VS2017 on Windows 10 Pro (x64) in a domain environment. I've been able to modify my code to make a call to System.Net.Dns.GetHostEntry so that I can get a valid IP as resolved by DNS for a named host before attempting to open the connection, but that seems a bit excessive. I need to have the ability/option to pass in a simple host name and not have MySql.Data break.
Here are the (obfuscated) details gathered by my application's error handler:
------------------------------------------------------------------------
EXCEPTION DETAILS
------------------------------------------------------------------------
Error Type: MySql.Data.MySqlClient.MySqlException
Error Source: MySql.Data
Error Message: Unable to connect to any of the specified MySQL hosts.
------------------------------------------------------------------------
MYSQL DATABASE ERROR DETAILS
------------------------------------------------------------------------
Database Error: Unable to connect to any of the specified MySQL hosts.
Error Code: -2147467259
------------------------------------------------------------------------
STACK TRACE
------------------------------------------------------------------------
at MySQLDB.Open() in clsMySQL.vb:line 1175
at MySQLDB.TestConnection() in clsMySQL.vb:line 852
at ValidateUser() in DataTier.vb:line 2538
------------------------------------------------------------------------
EXCEPTION DATA
------------------------------------------------------------------------
Server Error Code: 1042
ConnectionString: server=<SERVERNAME>;port=3306;database=<DBNAME>;user id=<USERNAME>;password=<PASSWORD>
Stack Trace from MySql.Data.MySqlClient:
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at MySQLDB.Open() in clsMySQL.vb:line 1169
------------------------------------------------------------------------
INNER EXCEPTION
------------------------------------------------------------------------
Error Type: System.InvalidOperationException
Error Source: System.Core
Error Message: Sequence contains more than one matching element
Exception Level: 1
Stack Trace from Inner Exception (1):
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.NativeDriver.Open()
Please let me know if you require any additional information. Thank you.
↧
↧
Should I use the JSON data type? (no replies)
Hey, I am storing JSON data (lots of string entries) in mySQL table. I get that you should use the native JSON data type if you want to quickly access parts of the JSON. But I dont need to do that, I am only fetching the whole json and displaying it, not fetching individual parts.
So would not using the JSON data type, and using mediumtext instead be better for me performance wise? Or in any way at all? Would it save storage? Do you use the JSON data type?
Thanks very much in advance guys.
So would not using the JSON data type, and using mediumtext instead be better for me performance wise? Or in any way at all? Would it save storage? Do you use the JSON data type?
Thanks very much in advance guys.
↧
Partial Trusted Caller Support Question (no replies)
Hi,
Could anyone tell me if the Connector/NET dlls support partial trusted callers as downloaded or must a [assembly:AllowPartiallyTrustedCallers] be added to the source code?
Many thanks,
Lou
Could anyone tell me if the Connector/NET dlls support partial trusted callers as downloaded or must a [assembly:AllowPartiallyTrustedCallers] be added to the source code?
Many thanks,
Lou
↧
MySQL Connector 8.0.13 PowerShell .Parameters.AddWithValue() (no replies)
While using the MySql.Data.MySqlClient with the .Parameters.AddWithValue() for some odd reason the first argument of the AddWithValue is returned no matter what. So if you are creating a Function in PowerShell you MUST set some variable or $null to be equal to $oMySQLCommand.Parameters.AddWithValue() otherwise if you are depending on a return from the Function your value will be corrupted by the Argument being returned.
Oddly, it also does not return $false if the value is not found in the .CommandText() either so it seems to have no purpose whatsoever.
Example:
$oMySQLCommand = New-Object MySql.Data.MySqlClient.MySqlCommand
$oMySQLCommand.Connection = $oMySQLPrivilegedConnection
$oMySQLCommand.CommandText = $strMySQL_INSERT
# Must capture the .AddwithValue() else if within a Function and relying on the Return of the function you will be surprised.
$null = $oMySQLCommand.Parameters.AddWithValue("@employeeID", $employeeID)
Oddly, it also does not return $false if the value is not found in the .CommandText() either so it seems to have no purpose whatsoever.
Example:
$oMySQLCommand = New-Object MySql.Data.MySqlClient.MySqlCommand
$oMySQLCommand.Connection = $oMySQLPrivilegedConnection
$oMySQLCommand.CommandText = $strMySQL_INSERT
# Must capture the .AddwithValue() else if within a Function and relying on the Return of the function you will be surprised.
$null = $oMySQLCommand.Parameters.AddWithValue("@employeeID", $employeeID)
↧
MySQL authentication error with .NET connector 8.0 (no replies)
When we use the .NET connector to connect to our emote MySQL we get the error below.
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host 'XX.XXX.XXX.XX' for user 'YYYYYYY' using method 'mysql_native_password' failed with message: Access denied for user 'YYYYYYY'@'ZZZ.ZZZ.ZZZ.ZZZ' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Access denied for user 'YYYYYYY'@'ZZZ.ZZZ.ZZZ.ZZZ' (using password: YES)
We have used the code below to generate the connection string.
var builder = new MySqlConnectionStringBuilder();
builder.Server = "XX.XXX.XXX.XX";
builder.UserID = "YYYYYYY";
builder.Password = "PPPPPPPPPPP";
builder.SslCa = @"D:\certs\server-ca.pem";
builder.SslKey = @"D:\certs\client-key.pem";
builder.SslCert = @"D:\certs\client-cert.pem";
builder.SslMode = MySqlSslMode.VerifyFull;
builder.Database = "noodlewatch";
builder.Port = 3306;
builder.Pooling = true;
builder.UseCompression = true;
MySqlConnection conn = new MySqlConnection(builder.ConnectionString);
We thought it has to do with the password and reset it and it still didn't work, have been able to connect to it successfully using HeidiSQL and so there doesn't seem to be any problem at the server end.
Any ideas on what needs to be done?
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host 'XX.XXX.XXX.XX' for user 'YYYYYYY' using method 'mysql_native_password' failed with message: Access denied for user 'YYYYYYY'@'ZZZ.ZZZ.ZZZ.ZZZ' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Access denied for user 'YYYYYYY'@'ZZZ.ZZZ.ZZZ.ZZZ' (using password: YES)
We have used the code below to generate the connection string.
var builder = new MySqlConnectionStringBuilder();
builder.Server = "XX.XXX.XXX.XX";
builder.UserID = "YYYYYYY";
builder.Password = "PPPPPPPPPPP";
builder.SslCa = @"D:\certs\server-ca.pem";
builder.SslKey = @"D:\certs\client-key.pem";
builder.SslCert = @"D:\certs\client-cert.pem";
builder.SslMode = MySqlSslMode.VerifyFull;
builder.Database = "noodlewatch";
builder.Port = 3306;
builder.Pooling = true;
builder.UseCompression = true;
MySqlConnection conn = new MySqlConnection(builder.ConnectionString);
We thought it has to do with the password and reset it and it still didn't work, have been able to connect to it successfully using HeidiSQL and so there doesn't seem to be any problem at the server end.
Any ideas on what needs to be done?
↧
↧
8.0 .net connector for 5.7 server (no replies)
Hello,
I am using mysql server 5.7.
For the clients I develop I am using the 8.0 .net connector.
For some reason I am getting "Bad handshake" while connecting, although the connection succeeds.
What may be the cause for the bad handshake?
May it be the versions difference?
Thanks
I am using mysql server 5.7.
For the clients I develop I am using the 8.0 .net connector.
For some reason I am getting "Bad handshake" while connecting, although the connection succeeds.
What may be the cause for the bad handshake?
May it be the versions difference?
Thanks
↧
Attempt to create ADO.NET Entity Data Model in Visual Studio 2017 fails on latest versions of Connector/NET (3 replies)
Trying to create an ADO.NET Entity Data Model in Visual Studio 2017 fails with version of Connector/NET other than version 6.9.10. So, I'm using that version. But keeping myself restricted to that version appears to causing new bugs to rise up.
↧
8.0.18 A null was returned after calling the 'GetService' method on a store provider instance of type 'MySql.Data.MySqlClient.MySqlClientFactory'. (no replies)
I have a working Website with MySQL 6.9.12 and EF. I am in the process of trying to move this website to a MySQL Server running version 8 with .Net Connector 8.0.18.
I am getting the following message:
A null was returned after calling the 'GetService' method on a store provider instance of type 'MySql.Data.MySqlClient.MySqlClientFactory'. The store provider might not be functioning correctly.
I have updated all references, so what am I missing?
I am getting the following message:
A null was returned after calling the 'GetService' method on a store provider instance of type 'MySql.Data.MySqlClient.MySqlClientFactory'. The store provider might not be functioning correctly.
I have updated all references, so what am I missing?
↧