-
C# 建立SQL Server数据库连接的基本方法
C# 建立SQL Server数据库连接的基本方法,核心代码为:
try
{
string ConStr =//创建数据库连接字符串
@"server=WIN-GI7E47AND9RLS;user id=sa;pwd=;database=db_TomeTwo";
SqlConnection con = new SqlConnection(ConStr);//创建数据库连接对象
string SqlStr = "select * from 帐单";//创建SQL查询字符串
SqlDataAdapter ada = new SqlDataAdapter(SqlStr, con);//创建数据适配器对象
DataSet ds = new DataSet();//创建数据表
ada.Fill(ds);//填充数据集
this.dgv_Message.DataSource =//设置数据源
ds.Tables[0].DefaultView;
}
catch(Exception ex)//捕获异常
{
MessageBox.Show(ex.Message,"提示!");//弹出消息对话框
}
- 2022-07-28 04:06:36下载
- 积分:1
-
半条命II游戏源代码
半条命II游戏源代码,这是完整的企业级游戏源码,采用vc6编写。是开发大型游戏的必备参考,非常有价值。
- 2022-03-23 19:15:28下载
- 积分:1
-
C# 自绘式按钮的实例 源码
C# 自绘式按钮的实例源码,本例主要是以复合控件方式创建自绘式按钮,并测试了自绘式按钮响应鼠标单击事件。自绘按钮的绘制,可以参考以下代码:
//绘制新按钮
Graphics MyGraphics = e.Graphics;
Point[] MyPtsA = { new Point(0, 0), new Point(90, 0), new Point(170, 0), new Point(170, 50), new Point(170, 90), new Point(90, 90), new Point(0, 90), new Point(0, 50) };
Color[] MyColsA = { Color.White, Color.Black, Color.White, Color.Black, Color.White, Color.Black, Color.White, Color.Black };
PathGradientBrush MyPGBrushA = new PathGradientBrush(MyPtsA);
MyPGBrushA.SurroundColors = MyColsA;
MyGraphics.FillRectangle(MyPGBrushA, 0, 0, 170, 90);
String MyText = "自绘式按钮";
Font MyFont = new Font("隶书", 22);
SolidBrush MyBrush = new SolidBrush(Color.White);
PointF MyPoint = new PointF(3.0F, 30.0F);
MyGraphics.DrawString(MyText, MyFont, MyBrush, MyPoint);
- 2022-06-30 07:08:12下载
- 积分:1
-
C# 以浮雕效果显示图片
Visual C# 以浮雕效果显示图像控件中的图像,private void Window_Loaded(object sender, RoutedEventArgs e)
{//以浮雕效果显示图像控件中的图像
var MyEmbossBitmapEffect = new System.Windows.Media.Effects.EmbossBitmapEffect();
MyEmbossBitmapEffect.LightAngle = 320;
MyEmbossBitmapEffect.Relief = 0.8;
this.image1.BitmapEffect = MyEmbossBitmapEffect;
}
- 2022-05-23 11:20:57下载
- 积分:1
-
鬼影源码去验证码3389 版本 用户
鬼影源码去验证码3389 版本 用户 鬼影源码去验证码非常好用的
- 2023-02-13 00:05:04下载
- 积分:1
-
C# 读取MP3歌曲文件标志信息并使用Quartz库播放
C# 读取MP3歌曲文件标志信息并使用Quartz库播放、读取WAV歌曲文件标志信息、使用Quartz库播放MP3歌曲、使用Quartz库播放DVD视频、弹出光驱、关闭光驱等功能,获取的MP3文件信息包括歌名、艺术家、签名册、发行日期等。同时还可以读取WAV歌曲文件标志信息,具体的标记信息请下载本源码查看Form1.cs文件。本实例部分功能需要依赖Interop.QuartzTypeLib.dll组件来实现。
- 2023-05-14 15:55:02下载
- 积分:1
-
C# 制作一个顶层显示的窗口-不被其它窗口遮挡
C#设置顶层显示的窗口,让窗口显示在其它窗口的最上面,不被遮挡,这种窗口形式或许大家平时都见到过,特别是一些视频播放器,在播放视频的时候,都可以设置是否顶层显示,本示例就是模拟了这个功能,通过“允许以最顶层方式显示窗口”和“禁止以最顶层方式显示窗口”来模拟启用和关闭顶层窗口的功能,代码貌似简单:
private void button1_Click(object sender, RoutedEventArgs e)
{//允许以最顶层方式显示窗口
this.Topmost = true;
}
private void button2_Click(object sender, RoutedEventArgs e)
{//禁止以最顶层方式显示窗口
this.Topmost = false;
}
- 2023-05-27 13:10:03下载
- 积分:1
-
C# 填充和格式化DataGridView单元格数据
C# 填充和格式化DataGridView单元格数据,这个例子对C#操作数据来说,是很有必要掌握的,特别是DataGridView控件的使用,很普遍,本示例主要演示了两个dataGrid组件功能,一是格式化DataGridView控件的指定单元格,二是填充DataGridView控件(dataGridView1)数据,下面来看C#填充DataGridView控件数据的代码:
var MyConnectionString ="Data Source=.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";
var MySQL = "Select OrderID,RequiredDate,ShippedDate,ShipVia From Orders";
var MyConnection = new System.Data.SqlClient.SqlConnection(MyConnectionString);
var MyAdapter = new System.Data.SqlClient.SqlDataAdapter(MySQL, MyConnection);
var MyTable = new DataTable();
MyAdapter.Fill(MyTable);
this.dataGridView1.DataSource = MyTable;
运行效果如下图所示,更多代码请下载源码包编译运行吧。
- 2022-05-07 18:45:47下载
- 积分:1
-
将DataGridView中内容导出到Word
Visual C# 2012 将数据生成Word表格文件,将DataGridView中内容导出到Word,这个程序的实现需要使用到几个Office编程库:Interop.Office.dll、Interop.VBIDE.dll、Interop.Word.dll。
实现步骤:实例化SqlConnection连接对象,创建数据库连接,SqlDataAdapter对象,填充DataSet对象,为DataGridView控件设置数据源。然后实例化Word文档对象,声明Word选区,建立Word对象,将数据生成Word表格文件,设置列宽,使用for循环输出列标题数据,最后输出控件中的记录。
- 2022-07-08 20:36:37下载
- 积分:1
-
C# 显示选择的DataGridView单元格行数据
C# 显示选择的DataGridView单元格行数据附实现源码,连接数据库后,单击上部的“显示选择的单元格行”功能,即可显示出该行数据,具体的实现代码如下:
private void toolStripButton1_Click(object sender, EventArgs e)
{//显示选择的单元格行(获取DataGridView控件中选定的单元格行)
Int32 MyCount =customersDataGridView.Rows.GetRowCount(DataGridViewElementStates.Selected);
if (MyCount > 0)
{
System.Text.StringBuilder MyInfo = new System.Text.StringBuilder();
for (int i = 0; i < MyCount; i++)
{
MyInfo.Append("被选择的行号是: ");
MyInfo.Append(customersDataGridView.SelectedRows[i].Index.ToString());
MyInfo.Append(Environment.NewLine);
}
MyInfo.Append("一共选择了: " + MyCount.ToString()+"行。");
MessageBox.Show(MyInfo.ToString(), "信息提示",MessageBoxButtons.OK);
}
}
- 2022-12-31 00:55:04下载
- 积分:1