Results 1 to 5 of 5

Thread: ASP.NET 2 connection to MySQL

  1. #1
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ASP.NET 2 connection to MySQL

    Hi,

    I've just signed up to RFH and so far I'm very impressed. I've just hit a bit of a problem with connecting to a MySQL database from ASP.NET 2.0

    I've created the MySQL database and user with no problems, copied the data across successfully, but get the following error when trying to access the data with ASP.NET 2 code :

    Security Exception : That assembly does not allow partially trusted callers.

    Having tried to set the trusted level to medium in my web.config, which didn't work, I'm now a bit stuck....

    Can anyone please help ? Is there a best practice to be followed when connecting to MySQL from ASP.NET 2.0 ? Do I need to use MSSQL instead ?

    Thanks.

  2. #2
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Can you post your connection code?
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here is my connection code :


    Dim
    cmdSelect AsNew MySqlCommand
    Dim conContent AsNew MySqlConnection
    Dim dadContent As MySqlDataAdapter
    Dim dstContent As Data.DataSet
    conContent =
    New MySqlConnection(ConfigurationManager.ConnectionStr ings("dbname").ConnectionString)
    dadContent =
    New MySqlDataAdapter("SELECT content.Title,content.Summary,content.ID,content.I mage,types.title AS title2 FROM content JOIN types ON content.type = types.id ORDER BY content.ID DESC LIMIT 10", conContent)
    conContent.Open()
    dstContent =
    New Data.DataSet
    dadContent.Fill(dstContent)
    dgrdContent.DataSource = dstContent
    dgrdContent.DataBind()
    conContent.Close()

    My connection string is stored in the web.config file as follows (with ip address,id and password changed for the purpose of this reply):

    <connectionStrings>
    <
    addname="dbname"connectionString="Server=myipaddress; user id=myid; password=mypassword; database=prcontent;Allow Zero Datetime=true;"
    providerName="MySql.Data.MySqlClient" />

    </
    connectionStrings>


    Thanks for your help. This way of connecting may not be the most efficient or up to date - but it works fine on localhost during testing.

  4. #4
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Good news - I've solved my problem.

    I approached it from another angle by doing the following :

    1. Created a new ODBC dsn using Helm.
    2. Created a new SqlDataSource using ASP.NET 2.0 and this new dsn (to MySQL database)
    3. Used a GridView to access the data using the new SqlDataSource

    This all works perfectly now.

    Thanks anyway - I should have tried this first.....

  5. #5
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    No problem, glad you got it working with ODBC
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. MySQL 5 Connection String
    By bracora.com in forum ASP.NET
    Replies: 1
    Last Post: 16th May 2006, 02:37 PM
  2. asp.net connection to mysql
    By keyur_ptl in forum ASP.NET
    Replies: 1
    Last Post: 27th January 2006, 11:26 AM
  3. ASP.NET 2 connection to MySQL - me too
    By madwab in forum ASP.NET
    Replies: 37
    Last Post: 10th January 2006, 06:13 AM
  4. asp.net db connection
    By creativeworks in forum ASP.NET
    Replies: 34
    Last Post: 8th November 2005, 03:53 PM
  5. Connection to MySql using ASP / JScript
    By JohnHorne in forum ASP (VBScript)
    Replies: 2
    Last Post: 17th July 2005, 05:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •