首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > 其他 > 测试链接并显示查询数据

测试链接并显示查询数据

  • 资源大小:0.25M
  • 上传时间:2021-07-24
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: 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;//Download by http://down.liehuo.netusing System.Data.SqlClient;namespace Case05_12{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { //生成连接数据库字符串 string ConStr = "data source=.;database=ljp;uid=sa;pwd=123"; //定义SqlConnection对象实例 SqlConnection con = new SqlConnection(ConStr); //定义Select查询语句 string Sql = "select*from biaoge"; SqlDataAdapter ada = new SqlDataAdapter(Sql, con); DataSet ds = new DataSet(); //定义DataSet对象实例 ada.Fill(ds); //连接数据表格,显示数据 this.dataGridView1.DataSource = ds.Tables[0].DefaultView; } catch { return; } } private void button2_Click(object sender, EventArgs e) { this.Close(); Application.Exit(); } }}
VIP VIP
0.191250s