If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Connect mysql via oledb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-01-08, 10:34
Racker Racker is offline
Registered User
 
Join Date: Sep 2008
Posts: 2
Unhappy 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
Reply With Quote
  #2 (permalink)  
Old 09-01-08, 11:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
For one thing your SQL is invalid... text needs surrounded by single quotes.
Code:
VALUES (1, 'Drinnen')
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 09-02-08, 15:57
Racker Racker is offline
Registered User
 
Join Date: Sep 2008
Posts: 2
Thanks for that hint.
The rest I solved, too
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On