本文介绍了未定义类型'MySqlConnection'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在app_code中创建函数调用类时,我在以下代码上遇到错误.
I am facing the error on the below code while i created a function call class at app_code.
我的错误正在显示-> BC30002:类型'MySqlConnection'未定义.请帮忙.谢谢!
My error is showing -->BC30002: Type 'MySqlConnection' is not defined. Please help.Thanks!
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net.Mail
Imports MySql.Data.MySqlClient
Namespace check90daysreturn
Public Class Check90days
Public Function check(ByVal datereceived As String, ByVal shipdate As String, ByVal partsn As String)
Dim con As String = ConfigurationManager.ConnectionStrings("xxxConnectionString").ConnectionString
Dim Sql As New MySqlConnection(con)
Dim reader2 As Object
Dim theQuery2 As String = "SELECT Max(shipmentdate) FROM prc.tbsrparts t WHERE Substring(partsn, 17, 11) = '" + partsn.ToString + "'" 'get latest shipment date from database
Dim command2 As New MySqlCommand(theQuery2, Sql)
reader2 = command2.ExecuteScalar
'send auto email
Dim mailmssg As New MailMessage()
Dim smtp_client As New SmtpClient
mailmssg.IsBodyHtml = True
smtp_client = New SmtpClient
smtp_client.Host = "ll.smtp.xxxxx.com"
smtp_client.Port = 25
mailmssg.From = New MailAddress("[email protected]")
mailmssg.CC.Add("[email protected]")
mailmssg.Subject = "(Testing)"
mailmssg.Body = "Testing"
smtp_client.DeliveryMethod = SmtpDeliveryMethod.Network
smtp_client.Send(mailmssg)
End Function
End Class
End Namespace
推荐答案
我遇到了同样的错误.
I got the same error.
添加后
Imports MySql.Data.MySqlClient;
,以及对MySql.Data.dll
的引用,我得到了' MySqlConnection未定义'.
, and a reference to the MySql.Data.dll
I got 'MySqlConnection is not defined'.
我已通过添加较旧版本的引用MySql.Data.dll
(而不是V4.5
)来解决此问题.
I have fixed it by adding the reference MySql.Data.dll
from the older version that is V2.0
instead of V4.5
.
这篇关于未定义类型'MySqlConnection'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!