在哪里可以找到有关使用MySQL设置ASP.NET Web应用程序的信息?

时间:2011-06-29 00:49:11

标签: .net asp.net mysql visual-studio-2010 web-applications

我有兴趣使用MySQL在ASP.NET中开发Web应用程序,这是难以实现的/它是否可以轻松地与Visual Studio 2010集成?我真的很喜欢将.NET平台用于Web应用程序,但我更喜欢使用MySQL而不是Microsoft SQL Server。有人可以解决一些问题/指导我建立良好的联系吗?

很抱歉,如果这是一个荒谬的问题,我是Web应用程序和.NET框架的新手。

2 个答案:

答案 0 :(得分:4)

尝试启动其中一些链接

Using MySQL with ASP.NET

Connect to MySQL database from ASP.NET

Using MySQL with ASP.NET

编辑:看起来您必须使用ODBC连接。您需要set up an ODBC connection on your PC以及部署应用程序的任何位置。这是我在连接到使用ODBC连接的Informix数据库时使用的示例。您需要install the drivers for MySql first

Informix数据库的Web.config连接字符串

<add name="odbcConnection" connectionString="Driver={IBM INFORMIX 3.82 32 BIT};uid=odbcUsername;pwd=odbcPassword;database=odbcDatabase; host=odbcHostName;srvr=odbcServerName;serv=odbcServ;pro=onsoctcp;cloc=en_US.819;dloc=en_US.819;vmb=0;condb=1;xcl=0;curb=0;scur=0;icur=0;oac=1;optofc=0;rkc=0;odtyp=0;fbs=4096;ddfp=0;dnl=0;rcwc=0" providerName="System.Data.Odbc"/>

DataAccess方法

Dim cnStr As String = ConfigurationManager.ConnectionStrings("odbcConnection").ToString

Public Function GetTable() As Data.DataSet
    Dim ds As New Data.DataSet
    Dim sql As String = ""

        Using myConnection As OdbcConnection = New OdbcConnection(cnStr)
            Dim myCommand As New OdbcCommand()
            Dim oda As OdbcDataAdapter = New OdbcDataAdapter()
                sql = "SELECT * FROM table"

                If myConnection.State = ConnectionState.Closed Then
                    myConnection.Open()
                    myCommand = New OdbcCommand(sql, myConnection)
                    myCommand.CommandType = CommandType.Text
                    oda.SelectCommand = myCommand
                    oda.Fill(ds, "tblInfo")
                End If
        End Using
    Return ds
End Function

答案 1 :(得分:0)

您可以将Mysql.Data Nuget Package添加到您的项目中,然后只需更改mysql服务器的连接字符串即可。

相关问题