Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > .NET Framework > Forum > ช่วยอธิบายการต่อ app ที่เขียนด้วย asp.net (C#) กับ mysql ด้วยค่ะ



 

[.NET] ช่วยอธิบายการต่อ app ที่เขียนด้วย asp.net (C#) กับ mysql ด้วยค่ะ

 



Topic : 026523



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์




ช่วยอธิบายการต่อ app ที่เขียนด้วย asp.net (C#) กับ mysql ด้วยค่ะ

ต้องตั้งค่าอะไรบ้าง หรือต้องใช้connector อะไรบ้าง

ขอตัวอย่าง source code ได้ด้วยก็ดีค่ะ

ขอบคุณมากค่ะ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-04-21 17:33:58 By : lookja View : 1711 Reply : 4
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ใช้ Connector ของ MySql.Data.MySQLClient ครับ

ASP.NET MySql.Data.MySQLClient

ในบทเรียนผมทำส่วนของ C# เสร็จแล้วน่ะครับ แต่ยังเอาขึ้นไม่เสร็จครับ

ผมส่งตัวอย่างมาคร่าว ๆ น่ะครับ

Code (C#)
01.<%@ Import Namespace="System.Data"%>
02.<%@ Import Namespace="MySql.Data.MySqlClient"%>
03.<%@ Page Language="C#" Debug="true" %>
04.<script runat="server">
05. 
06.    MySqlConnection objConn;
07.    MySqlCommand objCmd;
08. 
09.    void Page_Load(object sender,EventArgs e)
10.    {
11.        String strConnString;
12.        strConnString = "Server=localhost;User Id=root; Password=root; Database=mydatabase; Pooling=false";
13.        objConn = new MySqlConnection(strConnString);
14.        objConn.Open();
15. 
16.        BindData();
17.    }
18. 
19.    void BindData()
20.    {
21.        String strSQL;
22.        strSQL = "SELECT * FROM customer";
23. 
24.        MySqlDataReader dtReader;
25.        objCmd = new MySqlCommand(strSQL, objConn);
26.        dtReader = objCmd.ExecuteReader();
27.         
28.        //*** BindData to Repeater ***//
29.        myRepeater.DataSource = dtReader;
30.        myRepeater.DataBind();
31. 
32.        dtReader.Close();
33.        dtReader = null;
34. 
35.    }
36. 
37.    void Page_UnLoad()
38.    {
39.        objConn.Close();
40.        objConn = null;
41.    }
42. 
43.</script>
44.<html>
45.<head>
46.<title>ThaiCreate.Com ASP.NET - MySql</title>
47.</head>
48.<body>
49.    <form id="form1" runat="server">
50.    <asp:Repeater id="myRepeater" runat="server">
51.    <HeaderTemplate>
52.        <table border="1">
53.            <tr>
54.                <th>CustomerID</th>
55.                <th>Name</th>
56.                <th>Email</th>
57.                <th>CountryCode</th>
58.                <th>Budget</th>
59.                <th>Used</th>
60.            </tr>
61.    </HeaderTemplate>
62.    <ItemTemplate>
63.        <tr>
64.            <td align="center"><asp:Label id="lblCustomerID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CustomerID") %>'></asp:Label></td>
65.            <td><asp:Label id="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label></td>
66.            <td><asp:Label id="lblEmail" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Email") %>'></asp:Label></td>
67.            <td align="center"><asp:Label id="lblCountryCode" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CountryCode") %>'></asp:Label></td>
68.            <td align="right"><asp:Label id="lblBudget" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Budget") %>'></asp:Label></td>
69.            <td align="right"><asp:Label id="lblUsed" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Used") %>'></asp:Label></td>
70.        </tr>        
71.    </ItemTemplate>
72.    <AlternatingItemTemplate>
73.        <tr bgcolor="#e8e8e8">
74.            <td align="center"><asp:Label id="lblCustomerID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CustomerID") %>'></asp:Label></td>
75.            <td><asp:Label id="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label></td>
76.            <td><asp:Label id="lblEmail" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Email") %>'></asp:Label></td>
77.            <td align="center"><asp:Label id="lblCountryCode" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CountryCode") %>'></asp:Label></td>
78.            <td align="right"><asp:Label id="lblBudget" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Budget") %>'></asp:Label></td>
79.            <td align="right"><asp:Label id="lblUsed" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Used") %>'></asp:Label></td>
80.        </tr>        
81.    </AlternatingItemTemplate>
82.    </asp:Repeater>
83.    </form>
84.</body>
85.</html>







Date : 2009-04-21 17:52:22 By : webmaster
 


 

No. 2



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณมากค่ะ^^

Date : 2009-04-22 10:45:56 By : lookja
 

 

No. 3



โพสกระทู้ ( 5 )
บทความ ( 0 )



สถานะออฟไลน์


ทำไมพอรันแร้วมันถึงติดอยู่ที่ บันทัดนี้อ่ะค่ะ <%@ Import Namespace="MySql.Data.MySqlClient"%>

แล้วมันก้อฟ้องerrorว่า

Compiler Error Message: CS0234: The type or namespace name 'MySQLClient' does not exist in the namespace 'MySql.Data' (are you missing an assembly reference?)


แต่นู๋Add reference ไปแล้วนะค่ะ สงสัยมากเลยค่ะ

ช่วยบอกวิธีแก้ทีนะค่ะ

ขอบคุนค่ะ
Date : 2009-04-28 16:38:49 By : AnNie
 


 

No. 4



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code
<%@ Import Namespace="MySql.Data.MySqlClient"%>


MySqlClient ตัวพิมพ์เล็กพิมพ์ใหญ่ต่างกันน่ะครับ
Date : 2009-04-28 23:11:29 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยอธิบายการต่อ app ที่เขียนด้วย asp.net (C#) กับ mysql ด้วยค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่