Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2008
    Posts
    2

    Unhappy Unanswered: Connect mysql via oledb

    Hello ,

    I want to connect my asp.net /c# with the mysql database.
    But it doesn`t work.

    my web.config:

    <configuration>
    <appSettings>
    <add key="MM_CONNECTION_STRING" value="Provider= MSDataShape.1;Driver= {MySQL ODBC 3.51 Driver};Server= localhost;Database= xxxx;User Id= xxxx ;Password= xxxx;" />
    </appSettings>
    </configuration>



    my file:

    <%@ Page Language="C#" Debug="true"%>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.Configuration" %>
    <%@ Import Namespace="System.Data.OleDb" %>



    <script runat="server" >
    protected void Button1_Click(Object sender, EventArgs e) {

    string connStr = ConfigurationManager.AppSettings["MM_CONNECTION_STRING"].ToString();

    OleDbConnection MyConnection = new OleDbConnection(connStr);
    SqlDataAdapter MySqlCommand = new SqlDataAdapter ("INSERT INTO xxxx (WerbeID, Werbearten) VALUES (1, Drinnen)", MyConnection);




    }

    </script>



    The Output is:
    CS1502: The best overloaded method match for 'System.Data.SqlClient.SqlDataAdapter.SqlDataAdapt er(string, string)' has some invalid arguments

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    For one thing your SQL is invalid... text needs surrounded by single quotes.
    Code:
    VALUES (1, 'Drinnen')
    George
    Home | Blog

  3. #3
    Join Date
    Sep 2008
    Posts
    2
    Thanks for that hint.
    The rest I solved, too

Posting Permissions

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