VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
ODBC Posted by Wendy74 on 13 Jan 2010 at 6:28 AM
Hi all,

I transfered my mssql database to a mysql database (different webhost). It was difficult but I succeeded. Yeeh!
Now I need to use a ODBC Connection. My webhost gave me the connectionstring below, however my webpage gives the following error:
System.ArgumentException: Keyword not supported: 'driver'.

I think I have to adjust my code. I already changed SqlConnection into OdbcConnection, SqlCommand into OdbcCommand etc.
Could someone please help me? (I am new to programming)

The code I've got so far:
Imports Microsoft.Data.Odbc
Imports System.Data

Partial Class Bedrijvenindex
    Inherits System.Web.UI.Page

    Sub drpCategorie_SelectedIndexChanged(ByVal s As Object, ByVal e As EventArgs)
        adsrechts.Visible = "true"
        'geselecteerde CategorieID uitlezen
        Dim intCategorieID As Integer = drpCategorie.SelectedItem.Value
        'verbinding maken met de database en juiste bedrijven ophalen
        Dim conBedrijf As OdbcConnection
        Dim ConnectionString As String = "Driver={MySQL ODBC 5.1 Driver};Server=***;Database=***;User=***; Password=***;Option=3;"
		
		Dim cmdSelectBedrijf As OdbcCommand
        Dim OdbcString As String
        conBedrijf = New OdbcConnection(ConnectionString)
        conBedrijf.Open()
        OdbcString = "SELECT * from Bedrijf WHERE CategorieID="
        OdbcString &= intCategorieID

        If intCategorieID = "6" Then OdbcString = "SELECT * from Bedrijf"
        If intCategorieID = "0" Then OdbcString = "SELECT * from Bedrijf WHERE CategorieID=0"
        If intCategorieID = "0" Then adsrechts.Visible = "false"

        Dim dtrBedrijf As OdbcDataReader
        conBedrijf = New OdbcConnection(ConnectionString)
        conBedrijf.Open()
        cmdSelectBedrijf = New OdbcCommand(OdbcString, conBedrijf)
        dtrBedrijf = cmdSelectBedrijf.ExecuteReader()

        'opgehaalde gegevens binden aan repeater
        rptCategorie.DataSource = dtrBedrijf
        rptCategorie.DataBind()
        dtrBedrijf.Close()
        conBedrijf.Close()
    End Sub

End Class


Report
Re: ODBC Posted by seancampbell on 13 Jan 2010 at 9:21 AM
Chances are you are using the wrong connectionstring, visit this site and pick the connection string that best fits your scenario:

http://connectionstrings.com/mysql

-Seancampbell
Firesickle.com
Report
Re: ODBC Posted by Wendy74 on 13 Jan 2010 at 11:33 AM
Thanks for your reply Sean.

But according to this page (and my webhost) I must use: Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
and that is exactly what I'm doing..

So any other ideas?
Report
Re: ODBC Posted by Wendy74 on 13 Jan 2010 at 2:18 PM
My webhost told me to ad:
<assemblies>
<add assembly="MySql.Data, Version=6.0.4.0, Culture=neutral, PublicKeyToken=C568734FC88979C44D"/>
</assemblies>

but now I get the following error:
Could not load file or assembly 'MySql.Data\, Version\=6.0.4.0\, Culture\=neutral\, PublicKeyToken\=C568734FC88979C44D' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

How do I solve this?




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.