HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

Rate It (1)

Last post 07-31-2008 2:28 AM by Sajith G.S.. 11 replies.

Sort Posts:

  • HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-11-2007, 9:02 PM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    Ok, I'm pretty new to this.... I'm trying to connect mySql 5.0 with asp.net 2003...

    i have looked at sites, on how to get this done correctly, but now having trouble.... this site is the one i followed, because it seems

    simple...

    http://www.15seconds.com/issue/050210.htm

     I downloaded and did what all the instruction tells me to... but now when it comes to the apsx page,

    I'm not sure where they all go, look for my remarks here with ***

    *** I'm not sure with to put this... do i put it under my

    web form designer code following be everything else?  

    look at the original code on the above site.

    <%@ Page Language="VB" debug="true" %>
    <%@ Import Namespace = "System.Data" %>
    <%@ Import Namespace = "MySql.Data.MySqlClient" %>
    <script language="VB" runat="server">

    *** all % gets an blue underline and script language
    *** ----------------------------------- ***


    Sub Page_Load(sender As Object, e As EventArgs)

        Dim myConnection  As MySqlConnection   *** i get an blue underline
        Dim myDataAdapter As MySqlDataAdapter  *** i get an blue underline
        Dim myDataSet     As DataSet

        Dim strSQL        As String
        Dim iRecordCount  As Integer

        myConnection = New MySqlConnection("server=localhost; user id=15secs; password=password; database=mydatabase; pooling=false;")  *** mySQLConnection gets an blue underline

        strSQL = "SELECT * FROM mytable;"

        myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)  *** MySqlDataAdapter gets an blue underline
        myDataSet = New Dataset()
        myDataAdapter.Fill(myDataSet, "mytable")

        MySQLDataGrid.DataSource = myDataSet
        MySQLDataGrid.DataBind()

    End Sub

    </script>

    <html>
    <head>
    <title>Simple MySQL Database Query</title>
    </head>
    <body>

    <form runat="server">

    <asp:DataGrid id="MySQLDataGrid" runat="server" />

    </form>

    </body>
    </html>

     

    If anyone don't mind, can you create one and copy it on and post it up  and tell me how to do it please!

    I've been trying to fix it for the past couple of days....

    One more question does anyone know how to use tom cat?

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-12-2007, 12:15 AM

    Hey

    You could create a web form and paste the above code.

    Make sure MySql.Data.dll  is referenced.

    If you have problems ,pls post here.

    As for Tomcat you 'd better serach on internet you can find loads of tutorials.

    NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
    __________________________________________________

    Sincerely,
    Young Fang
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-12-2007, 5:36 AM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8
    Young Fang - MSFT:

    Hey

    You could create a web form and paste the above code.

    Make sure MySql.Data.dll  is referenced.

    If you have problems ,pls post here.

    As for Tomcat you 'd better serach on internet you can find loads of tutorials.

     

    i have copied the above in a webf form , but how do i referenced MySql.Data.dll?

    i will also look into how to reference it, but if i can't solve it. anyone who knows, please let me know. 

    as for tomcat, i've found some tutorials, but if i need help is there a tomcat forum too or of some sort?

     thank you in advance!! :)

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-13-2007, 4:57 PM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    okay.... i'm almost there please show me how to fix the error...

     i have already made a copy of the C:\Program Files\MySQL\MySQL Connector Net 1.0.4\bin\.NET 1.1\) to my application's /bin folder (ie. C:\Inetpub\wwwroot\bin\)

    and it still does not work please look over my mistakes or so.....

     my apsx page in html view(this is where i put the coding right?)

    or do i double click on design view and put the code there?

    http://i29.photobucket.com/albums/c296/LB3DR/connect_test_pagecopy.jpg

    http://i29.photobucket.com/albums/c296/LB3DR/connect_test_pagecopy_2.jpg

    http://i29.photobucket.com/albums/c296/LB3DR/connect_test_pagecopy_2.jpg" border="0" /> 

    this is what the error says:

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30002: Type 'MySqlConnection' is not defined.

    Source Error:

    Line 6:  Sub Page_Load(sender As Object, e As EventArgs)
    Line 7:  
    Line 8:  	Dim myConnection As MySqlConnection
    Line 9:  	Dim myDataAdapter As MySqlDataAdapter
    Line 10: 	Dim myDataSet As DataSet

    Source File: c:\inetpub\wwwroot\test_connection\WebForm1.aspx    Line: 8



    C:\WINDOWS\system32> "c:\windows\microsoft.net\framework\v1.1.4322\vbc.exe" /t:library /utf8output /R:"c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\test_connection\14f5f8d2\257c3447\bdlkobzm.dll" /R:"c:\windows\assembly\gac\system.web\1.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /R:"c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll" /R:"c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"c:\windows\assembly\gac\system.web.services\1.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\windows\assembly\gac\system.web.mobile\1.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\test_connection\14f5f8d2\257c3447\assembly\dl2\5962a2b6\20a5db5c_5937c701\test_connection.dll" /R:"c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll" /R:"c:\windows\assembly\gac\system.enterpriseservices\1.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\test_connection\14f5f8d2\257c3447\hldbrti4.dll" /D:DEBUG=1 /debug+  "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\test_connection\14f5f8d2\257c3447\hldbrti4.0.vb"
    
    
    Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
    for Microsoft (R) .NET Framework version 1.1.4322.2032
    Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
    
    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\test_connection\14f5f8d2\257c3447\hldbrti4.0.vb(16) : error BC30466: Namespace or type 'MySqlClient' for the Imports 'MySql.Data.MySqlClient' cannot be found.
    
    Imports MySql.Data.MySqlClient
            ~~~~~~~~~~~~~~~~~~~~~~
    c:\inetpub\wwwroot\test_connection\WebForm1.aspx(8) : error BC30002: Type 'MySqlConnection' is not defined.
    
        Dim myConnection As MySqlConnection
                            ~~~~~~~~~~~~~~~
    c:\inetpub\wwwroot\test_connection\WebForm1.aspx(9) : error BC30002: Type 'MySqlDataAdapter' is not defined.
    
        Dim myDataAdapter As MySqlDataAdapter
                             ~~~~~~~~~~~~~~~~
    c:\inetpub\wwwroot\test_connection\WebForm1.aspx(15) : error BC30002: Type 'MySqlConnection' is not defined.
    
        myConnection = New MySqlConnection("server=localhost; user id=test1; password=test1; database=mysales; pooling=false;")
                           ~~~~~~~~~~~~~~~                                                                                     
    c:\inetpub\wwwroot\test_connection\WebForm1.aspx(19) : error BC30002: Type 'MySqlDataAdapter' is not defined.
    
        myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
                            ~~~~~~~~~~~~~~~~                      
    
  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-13-2007, 5:26 PM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    ok got past the above situation....

    now its saying.....

    Server Error in '/test_connection' Application.

    A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied

    Source Error:

    Line 19: 	myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
    Line 20: 	myDataSet = New DataSet()
    Line 21: 	myDataAdapter.Fill(myDataSet, "mytable")
    Line 22: 	
    Line 23: 	MySQLDataGrid.DataSource = myDataSet

    Source File: c:\inetpub\wwwroot\test_connection\WebForm1.aspx    Line: 21

    Stack Trace:

    [SocketException (0x2749): A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied]
       System.Net.Sockets.Socket.Shutdown(SocketShutdown how) +188
       MySql.Data.Common.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 count) +72
       System.IO.BufferedStream.ReadByte() +113
       MySql.Data.MySqlClient.PacketReader.ReadHeader() +16
       MySql.Data.MySqlClient.PacketReader.OpenPacket() +107
       MySql.Data.MySqlClient.NativeDriver.Open() +729
       MySql.Data.MySqlClient.MySqlConnection.Open() +144
       System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
       System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
       ASP.WebForm1_aspx.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\test_connection\WebForm1.aspx:21
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +750
    


    Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

     

    what do I do next?  hopefully someone got here before and got help me out from here.... think i'm almost there!!! :)

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-15-2007, 12:43 AM

    Make sure not firewall blocks the connection.

    Also you could take a look at: http://forums.asp.net/3/1482362/ShowThread.aspx

    NOTE:If you find my response contains a reference to a third party World Wide Web site, I am providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,Microsoft cannot make any representations regarding the quality,safety, or suitability of any software or information found there.
    __________________________________________________

    Sincerely,
    Young Fang
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-15-2007, 8:06 PM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    ok, i downloaded the mysql.data.dll (that allows partial trust callers) from the link above. then i put it in my bin folder...

    now, i'm getting my old error again:

    Compiler Error Message: BC30002: Type 'MySqlConnection' is not defined.

    Source Error:

    Line 6:  Sub Page_Load(sender As Object, e As EventArgs)
    Line 7:   
    Line 8:  	Dim myConnection  As MySqlConnection
    Line 9:  	Dim myDataAdapter As MySqlDataAdapter
    Line 10: 	Dim myDataSet     As DataSet

    any other reference to related forums would be great! i really appreciate your help.  thanks and i'm still reading more forums and searchin....

     

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-15-2007, 8:09 PM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    if i put my old MySql.Data.dll, back in it shows the other error above....

    about socket connection disallowed.....

     

    Confused

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-15-2007, 8:09 PM
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    if i put my old MySql.Data.dll, back in it shows the other error above....

    about socket connection disallowed.....

     

    Confused

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    01-24-2007, 12:15 AM
    Answer
    • Loading...
    • pald
    • Joined on 01-12-2007, 1:47 AM
    • Fremont, Ca
    • Posts 8

    ok solved it!!!

    i didn't use the new mysql.data.dll (that allows partial trust callers), the one I downloaded from one of the links from a member assisting me in this.....

    you use the one that came with connector.net and put it in your bin folder of your project.....

     since i did not used the default port: 3306, i have to mention the port i'm using in my code!

     heres my syntax:

    everything else leave it the same and specify your port!  

    myConnection = New MySqlConnection("server=localhost; port=3309; user id=user01; password=user01; database=mydatabase; pooling=false;")

     

    ** without the correct port it gives you this ERROR:

    A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied

    Thanks for the help!!

    CONNECTION WORK!!

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    06-03-2008, 2:32 AM
    • Loading...
    • NWeb
    • Joined on 07-27-2007, 9:20 AM
    • Posts 20

     can u plz send me link the link to download that mysql.dll.since i also faced the same problem.

    Thanks in advanced. 

     

  • Re: HELP Please!! MySQL 5.0 Connection with ASP.NET 2003

    07-31-2008, 2:28 AM
    • Loading...
    • Sajith G.S.
    • Joined on 03-06-2008, 5:47 AM
    • Trivandrum
    • Posts 67

    Use port=3306
    sajith
Page 1 of 1 (12 items)
Microsoft Communities