using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace _20090107_BCS_資料庫_表單模式_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//直接撈 TABLE表
private void button2_Click(object sender, EventArgs e)
{
using (SqlConnection aaa = new SqlConnection("Data Source=10.1.1.253;Initial Catalog=BCS;User ID=sa;Password=fuchi4728")) //開啟連線
{
aaa.Open(); //打開
//string q1 = "SELECT * ";
//string q2= " FROM IWK_ACT ";
//string q3 = " WHERE S_NO LIKE 'FT5508A08C0186%'";
//string q5 = q1 + q2 + q3;
string q5 = textBox1.Text;
SqlDataAdapter cc = new SqlDataAdapter(q5.ToString(), aaa);
DataSet km = new DataSet();
cc.Fill(km);
dataGridView1.AutoGenerateColumns = true;
DataGridView kk = new DataGridView();
kk.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.DataSource = km.Tables[0];
MessageBox.Show("查詢完了");
}
}
}
}
沒有留言:
張貼留言