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,030

HOME > .NET Framework > Forum > อยาก ให้ พอขึ้น messagebox แล้ว ให้แสดง ตารางข้อมูลในฐานข้อมูล แสดงใน dataGridView ด้วยอะค่ะ เขียนโค้ดเพิ่ม ยังไง อะคะ ให้มันแสดงข้อมูลตาราง ที่เราเลือกจาก combobox ค่ะ



 

อยาก ให้ พอขึ้น messagebox แล้ว ให้แสดง ตารางข้อมูลในฐานข้อมูล แสดงใน dataGridView ด้วยอะค่ะ เขียนโค้ดเพิ่ม ยังไง อะคะ ให้มันแสดงข้อมูลตาราง ที่เราเลือกจาก combobox ค่ะ

 



Topic : 087597

Guest




หน้าออกแบบค่ะ

Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'cdrDataSet.hie_all_100' table. You can move, or remove it, as needed.
           
            // TODO: This line of code loads data into the 'cdrDataSet.hie_all' table. You can move, or remove it, as needed.
        
            comboBox1.Items.Add("ao-mt cdr output");
            comboBox1.Items.Add("hie_all");
            comboBox1.Items.Add("hie_all_100");
            comboBox1.Items.Add("hie_all_101");
            comboBox1.Items.Add("hie_all_102");
            comboBox1.Items.Add("hie_all_103");
            comboBox1.Items.Add("hie_all_105");
            comboBox1.Items.Add("hie_all_106");
            comboBox1.Items.Add("hie_all_107");
            comboBox1.Items.Add("hie_all_108");
            comboBox1.Items.Add("hie_all_110");
            comboBox1.Items.Add("hie_all_116");
            comboBox1.Items.Add("hie_all_117");
            comboBox1.Items.Add("hie_all_119");
            comboBox1.Items.Add("hie_all_120");
            comboBox1.Items.Add("hie_all_128");
            comboBox1.Items.Add("hie_all_130");
            comboBox1.Items.Add("hie_all_134");
            comboBox1.Items.Add("hie_all_138");
            comboBox1.Items.Add("hie_all_139");
            comboBox1.Items.Add("hie_all_140");
            comboBox1.Items.Add("hie_all_141");
            comboBox1.Items.Add("hie_all_142");
            comboBox1.Items.Add("hie_all_145");
            comboBox1.Items.Add("hie_all_146");
            comboBox1.Items.Add("hie_all_147");
            comboBox1.Items.Add("hie_all_148");
            comboBox1.Items.Add("hie_all_149");
            comboBox1.Items.Add("hie_all_150");
            comboBox1.Items.Add("hie_all_153");
            comboBox1.Items.Add("hie_all_154");
            comboBox1.Items.Add("hie_all_155");
            comboBox1.Items.Add("hie_all_156");
            comboBox1.Items.Add("hie_all_157");
            comboBox1.Items.Add("hie_all_159");
            comboBox1.Items.Add("hie_all_167");
            comboBox1.Items.Add("hie_all_168");
            comboBox1.Items.Add("hie_all_170");
            comboBox1.Items.Add("hie_all_171");
            comboBox1.Items.Add("hie_all_172");
            comboBox1.Items.Add("hie_all_176");
            comboBox1.Items.Add("hie_all_177");
            comboBox1.Items.Add("hie_all_178");
            comboBox1.Items.Add("hie_all_182");
            comboBox1.Items.Add("hie_all_183");
            comboBox1.Items.Add("hie_all_184");
            comboBox1.Items.Add("hie_all_185");
            comboBox1.Items.Add("hie_all_186");
            comboBox1.Items.Add("hie_all_187");
            comboBox1.Items.Add("hie_all_191");
            comboBox1.Items.Add("hie_all_192");
            comboBox1.Items.Add("hie_all_193");
            comboBox1.Items.Add("hie_all_194");
            comboBox1.Items.Add("hie_all_195");
            comboBox1.Items.Add("hie_all_196");
            comboBox1.Items.Add("hie_all_197");
            comboBox1.Items.Add("hie_all_198");
            comboBox1.Items.Add("hie_all_199");
            comboBox1.Items.Add("hie_all_204");
            comboBox1.Items.Add("hie_all_206");
            comboBox1.Items.Add("hie_all_209");
            comboBox1.Items.Add("hie_all_211");
            comboBox1.Items.Add("hie_all_212");
            comboBox1.Items.Add("hie_all_213");
            comboBox1.Items.Add("hie_all_216");
            comboBox1.Items.Add("hiq_all_ain");
            comboBox1.Items.Add("hiq_all_cf");
            comboBox1.Items.Add("hiq_all_fmc");
            comboBox1.Items.Add("hiq_all_queue");
            comboBox1.Items.Add("hiq_allinap");
            comboBox1.Items.Add("hiq_allqueue");
            comboBox1.Items.Add("Interim record");
            comboBox1.Items.Add("mo-at cdroput");
            comboBox1.Items.Add("nan_hiqoutput");
            comboBox1.Items.Add("sample_start_record");
            comboBox1.Items.Add("sample_stop_record");
            comboBox1.Items.Add("smsc");
            comboBox1.Items.Add("Start_record field");
            comboBox1.Items.Add("stop_record_field");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string var;
            var = comboBox1.Text;
            MessageBox.Show(var);
        }
    }
}



ตอนนี้หนูเขียนให้ แสดง ข้อความ showmessagebox ได้แล้ว คะ

แต่ อยาก ให้ พอขึ้น messagebox แล้ว ให้แสดง ตารางข้อมูลในฐานข้อมูล แสดงใน dataGridView ด้วยอะค่ะ

เขียนโค้ดเพิ่ม ยังไง อะคะ ให้มันแสดงข้อมูลตาราง ที่เราเลือกจาก combobox ค่ะ

ขอคำแนะนำจากพี่ๆ ด้วยนะค่ะ ขอบคุณค่ะ

ปล. หนูใช้ sql server 2005 เชื่อม นะคะ แล้วเขียน ภาษา C# ใช้ โปรแกรม VS 2008 ค่ะ



Tag : .NET, Ms SQL Server 2005, C#, VS 2008 (.NET 3.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-12-04 11:08:11 By : มือใหม่ค่ะ View : 974 Reply : 1
 

 

No. 1



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



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


มีตัวอย่างเยอะแยะเลยครับ

https://www.thaicreate.com/dotnet/vb.net-cs-connect-sqlserver-using-ado-net.html
https://www.thaicreate.com/dotnet/forum/065992.html


** ตรงส่วนที่ add item ตั้งแต่ hie_all_100 - hie_all_216 ใช้ for loop เอาก็ได้มั้งครับ จะได้เขียน code สั้นหน่อย








ประวัติการแก้ไข
2012-12-04 11:47:13
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-12-04 11:46:51 By : Nameless
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยาก ให้ พอขึ้น messagebox แล้ว ให้แสดง ตารางข้อมูลในฐานข้อมูล แสดงใน dataGridView ด้วยอะค่ะ เขียนโค้ดเพิ่ม ยังไง อะคะ ให้มันแสดงข้อมูลตาราง ที่เราเลือกจาก combobox ค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่