Results 1 to 2 of 2
Thread: My SQL Connection Sample Code
-
08-29-2005, 01:36 AM #1Retired Moderator
- Join Date
- Mar 2004
- Location
- Singapore
- Posts
- 6,990
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.
-
08-29-2005, 12:52 PM #2Web Hosting Master
- Join Date
- Jul 2004
- Posts
- 930
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 Object, e As 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(strSQL, myConnection)
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.