码迷,mamicode.com
首页 > Windows程序 > 详细

winfrom增删改查

时间:2016-02-17 14:24:24      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string connStr = "server=DESKTOP-QQGOIKH;uid=sa;pwd=123;database=t1";
        private void Form1_Load(object sender, EventArgs e)
        {
            string sql = "select * from student";
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds,"aa");
            conn.Close();
            DataTable dt= ds.Tables["aa"];
            dataGridView1.DataSource = dt;


                    }
    }
}

  

winfrom增删改查

标签:

原文地址:http://www.cnblogs.com/xiaz/p/5194977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!