9Mcode comment |
 |
 |
|
|
|
 |
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
 |
กระทู้ #3063 [.NET] (จาก IP: 110.164.44.126)
ดึงข้อมูลจาก mysql มาโชว์ที่ datagrid ยังไงครับ ขอบคุณล่วงหน้าครับ
ดึงข้อมูลจาก mysql มาโชว์ที่ datagrid ยังไงครับ ขอบคุณล่วงหน้าครับ
|
จากคุณ
:
mongkol / mongkolchoosrisert@hotmail.com [2011-04-08 13:04:14]
|
|
ความคิดเห็น #28292 (จาก IP: 101.108.1.204)
<%@ Page Language="C#" AutoEventWireup="False" EnableSessionState="False" EnableViewState="False" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.Odbc" %>
<script runat="server"> private const string ConnStr = "Driver={MySQL ODBC 3.51 Driver};" + "Server=localhost;Database=test;uid=root;pwd=yourpassword;option=3";
protected override void OnInit(EventArgs e) { base.OnInit(e);
using(OdbcConnection con = new OdbcConnection(ConnStr)) using(OdbcCommand cmd = new OdbcCommand("SELECT * FROM Names", con)) { con.Open(); dgrAllNames.DataSource = cmd.ExecuteReader( CommandBehavior.CloseConnection | CommandBehavior.SingleResult); dgrAllNames.DataBind(); } } </script>
<html> <head> <title>Displaying Records from MySQL 'Names' table</title> <style> body { font: 100% Verdana; } </style> </head> <body>
<p align="center">All records in the 'Names' table:</p>
<asp:DataGrid ID="dgrAllNames" HorizontalAlign="Center" CellPadding="3" Runat="server" />
</body> </html>
ข้อมูลจาก http://www.stardeveloper.com/articles/display.html?article=2003052201&page=9 |
จากคุณ
:
maddog [2011-04-08 13:58:03]
|
 |
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|
|
|