Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    6,946

    My SQL Connection Sample Code

    Anyone has sample code for calling MySQL connection in ASP. After calling maybe just display a "Tested Connection Working" or something like that?

    Some sort of script is best to test my clients' connection codes.

  2. #2
    I think this might be what ya want.
    http://www.15seconds.com/issue/050407.htm
    PHP Code:
     <%@ Page Language="VB" debug="true" %>
    <%@ 
    Import Namespace = "System.Data" %>
    <%@ 
    Import Namespace = "MySql.Data.MySqlClient" %>
    <
    script language="VB" runat="server">

    Sub Page_Load(sender As ObjectAs EventArgs)

        
    Dim myConnection  As MySqlConnection
        Dim myDataAdapter 
    As MySqlDataAdapter
        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;")

        
    strSQL "SELECT * FROM mytable;"

        
    myDataAdapter = New MySqlDataAdapter(strSQLmyConnection)
        
    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> 
    Last edited by Criminal#58369; 08-29-2005 at 01:05 PM.

  3. Newsletters

    Subscribe Now & Get The WHT Quick Start Guide!

Related Posts from theWHIR.com

Posting Permissions

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