登录
首页 » C# » 测试链接并显示查询数据

测试链接并显示查询数据

于 2014-10-02 发布
0 151
下载积分: 1 下载次数: 0

代码说明:

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(); } }}

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论


0 个回复

  • 微信平台
    微信平台
    2013-12-30下载
    积分:1
  • 海康dvr流媒体服务器+客户端
    海康dvr流媒体服务器+客户端
    2015-09-15下载
    积分:1
  • android_与C# socket服务端通信例子源码下载
    客户端是android,服务端是C#, 实现了 登陆以及客户端发消息给服务端
    2015-05-21下载
    积分:1
  • qrcode 识别(zbar-sharp)
    条码识别 【核心代码】 usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Diagnostics; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; usingSystem.Drawing.Imaging; usingThoughtWorks.QRCode.Codec; usingThoughtWorks.QRCode.Codec.Data; usingZBar; usingZXing; usingImage = System.Drawing.Image;
    2021-08-05 00:31:11下载
    积分:1
  • html5 超炫进度条实例源码(粒子效果)
    html5 超炫进度条实例源码(粒子效果)
    2014-08-04下载
    积分:1
  • C#三层架构0813—SqlServer带数据库-Vis-visual studio2019
        三层架构增加-删除-修改-查询可以提供学习交流,谢谢C#三层架构0813—SqlServer-Vis-visual studio2019
    2020-12-07下载
    积分:1
  • 白中英计算机组成原理ppt
    白中英计算机组成原理ppt
    2020-05-31下载
    积分:1
  • c# 通过int长度判断当前系统是64位还是32位
    c# 通过int长度判断当前系统是64位还是32位
    2014-01-27下载
    积分:1
  • 自动登录qq空间,获取最近访客列表.
    自动登录qq空间,获取最近访客列表.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 WindowsFormsApplication1{ public partial class Form1 : Form { Timer terAutologin = new Timer(); public Form1() { InitializeComponent(); terAutologin.Enabled = true; terAutologin.Interval = 3 * 1000; terAutologin.Tick = ter_Tick; } void ter_Tick(object sender, EventArgs e) { if(wb1.Document==null) { return; } HtmlElement dialog_content_1 = wb1.Document.GetElementById("dialog_content_1"); if (dialog_content_1 == null) { return; } var frame = wb1.Document.Window.Frames[0]; if (frame==null) { return; } if (frame.Document==null) { return; } // iframe HtmlElement u = frame.Document.GetElementById("u"); u.InnerText = "171586098"; HtmlElement p = frame.Document.GetElementById("p"); p.InnerText = "*************"; p.SetAttribute("value", "********"); HtmlElement login_button = frame.Document.GetElementById("login_button"); login_button.InvokeMember("click"); terAutologin.Stop(); } private void Form1_Load(object sender, EventArgs e) { ssl1.Text = string.Empty; txtUrl.Text = "http://user.qzone.qq.com/14371939"; wb1.ScriptErrorsSuppressed = true; wb1.Navigate("http://user.qzone.qq.com/14371939/main"); } private void btnGO_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUrl.Text)) { wb1.Navigate(txtUrl.Text); ssl1.Text = txtUrl.Text " Navigated"; } } private void wb1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { System.Diagnostics.Trace.WriteLine(e.Url.ToString()); // http://g.cnc.qzone.qq.com/cgi-bin/friendshow/cgi_get_visitor_simple?uin=4371939&type=1&mask=3&rd=0.7801240284461528&_=1397644130601&g_tk=9281770 ssl1.Text = e.Url.ToString() " Completed"; tryRead(); } private void btnTest_Click(object sender, EventArgs e) { tryRead(); } private void tryRead() { if (wb1.Document == null) { return; } HtmlElement pagediv = wb1.Document.GetElementById("visitor_list_page_con"); if (pagediv==null) { return; } //若分页内容存在,则表示已经加载过了. if(pagediv.Children.Count>0) { handlerAbc(null,null); return; } //模拟点击 "最近访客" var aa = pagediv.Parent.Parent.FirstChild.Children[2]; aa.InvokeMember("click"); //给访问列表的容器绑定一个事件...回调时就能获取到. HtmlElement guestlist = pagediv.Parent.FirstChild; //ul.RaiseEvent guestlist.AttachEventHandler("onpropertychange", new EventHandler(handlerAbc)); } private void handlerAbc(Object sender, EventArgs e) { HtmlElement div = wb1.Document.GetElementById("visitor_list_page_con"); HtmlElement guestlist = div.Parent.FirstChild; if (guestlist.InnerHtml.IndexOf("QZONE.FrontPage.showLoginBox") > -1) { HtmlElement alogin = guestlist.GetElementsByTagName("a")[0]; alogin.InvokeMember("click"); // 使用定时器.检测登录窗口的出现.. terAutologin.Start(); return; } else { System.Text.StringBuilder sb = new StringBuilder(); // 取回里面的内容? foreach (HtmlElement li in guestlist.Children) { string qq = li.GetAttribute("uin"); string visitname = li.Children[1].FirstChild.InnerText; string visittime = li.Children[1].Children[1].InnerText; sb.AppendLine(qq visitname visittime); } MessageBox.Show(sb.ToString()); } } }}
    2014-04-18下载
    积分:1
  • U3D调用windowsAPI的一些测试
    U3D调用windowsAPI的一些测试
    2013-08-07下载
    积分:1
  • 696518资源总数
  • 104544会员总数
  • 20今日下载