c#中处理关于SQL中BLOG大数据的方法
来源:互联网 发布:足球竞猜软件 编辑:程序博客网 时间:2024/06/08 06:34
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;using System.Data.SqlClient;using System.Data.Sql;using System.IO;namespace dbBlog{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder(); connBuilder.DataSource = "localhost"; connBuilder.InitialCatalog = "northwind"; connBuilder.IntegratedSecurity = true; using (SqlConnection conn = new SqlConnection(connBuilder.ToString())) { try { conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandText = "select firstname,lastname from employees"; using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { lbxImage.Items.Add(dataReader[0]+" "); } } } catch(Exception ex) { Console.WriteLine(ex.Message); } } } private void lbxImage_SelectedIndexChanged(object sender, EventArgs e) { if (lbxImage.SelectedIndex == -1) { return; } SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder(); connBuilder.DataSource = "localhost"; connBuilder.InitialCatalog = "northwind"; connBuilder.IntegratedSecurity = true; using (SqlConnection conn = new SqlConnection(connBuilder.ToString())) { try { conn.Open(); SqlCommand command = new SqlCommand(); command.Connection = conn; command.CommandText = "select firstName,lastName,photo from employees where firstName+' '+lastname=@name"; string name = lbxImage.SelectedItem.ToString(); command.Parameters.Add("@name",SqlDbType.NVarChar,100).Value=name; using (SqlDataReader dataReader = command.ExecuteReader(CommandBehavior.CloseConnection|CommandBehavior.SingleResult)) { if (dataReader.Read()) { String firstname = dataReader.GetString(0); System.Data.SqlTypes.SqlBytes bytes = dataReader.GetSqlBytes(2); try { pbxImage.Image = Image.FromStream(bytes.Stream); } //lbxImage.Items.Add(dataReader[0] + " "); catch (Exception ex) { Console.WriteLine(ex.Message); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } MessageBox.Show("123"); } private void pbxImage_Click(object sender, EventArgs e) { } }}
0 0
- c#中处理关于SQL中BLOG大数据的方法
- C#关于向数据库中插入数据时,有不规则自增列的处理方法
- 关于webgis中大数据量的处理方法
- 关于MS SQL Server中DATETIME类型数据的处理
- C#向Sql Server中插入记录时单引号的处理 选择自 davidullua 的 Blog
- 关于通信中数据接收的处理方法讨论
- C#关于取DataTable中中间数据的方法
- java中关于大数据类型的处理
- Oracle 中大数据的处理
- c#中关于日期的处理!
- 关于sql 中go的处理
- C#解决串口通信中接收数据时延迟处理与缓存处理的方法
- C#解决串口通信中接收数据时延迟处理与缓存处理的方法
- C#解决串口通信中接收数据时延迟处理与缓存处理的方法
- C#解决串口通信中接收数据时延迟处理与缓存处理的方法
- 关于Oracle中重复数据的处理
- C#中处理XML文档的方法
- C#中处理XML文档的方法
- hdu1978 How many ways
- 使用colorbox进行弹窗遇到的怪事,关闭弹窗报错colorbox undefined
- Linux内核中ioremap映射的透彻理解
- POJ 2653 Pick-up sticks
- 数据仓库篇章 OLTP/OLAP 区别
- c#中处理关于SQL中BLOG大数据的方法
- linux网络编程-服务器端线程池技术(C语言实现)
- window下设置apache虚拟主机
- [noj 1561] Set Time
- Java语言中的值传递与引用传递
- poj 3177 Redundant Paths
- Nginx学习之十-超时管理(定时器事件)
- Linux cron输出导致僵尸进程案例及解决
- XMPPFrameWork IOS 开发(一)xmpp简介