• 大小: 203KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: 数据库
  • 标签: VS2010  C#  OLEDB  

资源简介

using System.Data.OleDb; OleDbConnection connection = new OleDbConnection("Provider=MSDAORA; Data Source=数据库名_服务器IP地址;User Id=***;Password=***");//定义数据库的字符串 OleDbCommand catCMD = connection.CreateCommand();//定义连接数据库的命令 catCMD.CommandText = " SELECT * FROM student ";//定义对数据库操作的SQL语句 connection.Open();//打开连接

资源截图

代码片段和文件信息

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.OleDb;

namespace oledbwindows
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            try
            {
                OleDbConnection connection = new OleDbConnection(“Provider=MSDAORA; Data Source=orac2_10.178.116.50;User Id=lsj;Password=lsj123“);//定义数据库的字符串

                OleDbCommand catCMD = connection.CreateCommand();//定义连接数据库的命令
                catCMD.CommandText = “ SELECT * FROM student “;//定义对数据库操作的SQL语句

                connection.Open();//打开连接

                DataSet ds1 = new DataSet();//定义数据集,用来保存读取的内容
                OleDbDataAdapter da1 = new OleDbDataAdapter(catCMD);//读取数据表
                da1.Fill(ds1);//将数据加载到数据集中
                DataTable dt = ds1.Tables[0];//将数据放入表中
                connection.Close();//关闭数据连接
                this.dataGridView1.DataSource = dt.DefaultView;//数据显示 在dataGridView中显示
                this.dataGridView1.Refresh();//刷新dataGridView
                ds1.Dispose();//释放数据集
                dt.Dispose();//释放表
                catCMD.Dispose();//释放数据库命令
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8704  2012-08-03 16:08  oledbwindows\oledbwindows\bin\Debug\app.publish\Application Files\oledbwindows_1_0_0_1\oledbwindows.exe.deploy

     文件       7170  2012-08-03 16:08  oledbwindows\oledbwindows\bin\Debug\app.publish\Application Files\oledbwindows_1_0_0_1\oledbwindows.exe.manifest

     文件       5273  2012-08-03 16:08  oledbwindows\oledbwindows\bin\Debug\app.publish\oledbwindows.application

     文件     461720  2012-08-03 16:08  oledbwindows\oledbwindows\bin\Debug\app.publish\setup.exe

     文件       1586  2012-08-03 16:35  oledbwindows\oledbwindows\bin\Debug\oledbwindows.application

     文件       8704  2012-08-03 16:35  oledbwindows\oledbwindows\bin\Debug\oledbwindows.exe

     文件       3558  2012-08-03 16:35  oledbwindows\oledbwindows\bin\Debug\oledbwindows.exe.manifest

     文件      24064  2012-08-03 16:35  oledbwindows\oledbwindows\bin\Debug\oledbwindows.pdb

     文件       1586  2012-08-03 16:35  oledbwindows\oledbwindows\bin\Debug\oledbwindows.vshost.application

     文件      14328  2012-08-06 09:03  oledbwindows\oledbwindows\bin\Debug\oledbwindows.vshost.exe

     文件       5184  2012-08-03 16:01  oledbwindows\oledbwindows\bin\Debug\sqlnet.log

     文件       1778  2012-08-03 16:04  oledbwindows\oledbwindows\Form1.cs

     文件       2906  2012-08-03 16:04  oledbwindows\oledbwindows\Form1.Designer.cs

     文件       5814  2012-08-03 16:04  oledbwindows\oledbwindows\Form1.resx

     文件       1586  2012-08-03 16:35  oledbwindows\oledbwindows\obj\Debug\oledbwindows.application

     文件       1097  2012-08-06 09:03  oledbwindows\oledbwindows\obj\Debug\oledbwindows.csproj.FileListAbsolute.txt

     文件        847  2012-08-03 16:04  oledbwindows\oledbwindows\obj\Debug\oledbwindows.csproj.GenerateResource.Cache

     文件       8704  2012-08-03 16:35  oledbwindows\oledbwindows\obj\Debug\oledbwindows.exe

     文件       3558  2012-08-03 16:35  oledbwindows\oledbwindows\obj\Debug\oledbwindows.exe.manifest

     文件        180  2012-08-03 16:35  oledbwindows\oledbwindows\obj\Debug\oledbwindows.Form1.resources

     文件      24064  2012-08-03 16:35  oledbwindows\oledbwindows\obj\Debug\oledbwindows.pdb

     文件        180  2012-08-03 16:35  oledbwindows\oledbwindows\obj\Debug\oledbwindows.Properties.Resources.resources

     文件       5701  2012-08-03 16:35  oledbwindows\oledbwindows\oledbwindows.csproj

     文件        486  2012-08-03 16:35  oledbwindows\oledbwindows\oledbwindows.csproj.user

     文件       1652  2012-08-03 14:07  oledbwindows\oledbwindows\oledbwindows_TemporaryKey.pfx

     文件        493  2012-08-03 10:54  oledbwindows\oledbwindows\Program.cs

     文件       1372  2012-08-03 10:54  oledbwindows\oledbwindows\Properties\AssemblyInfo.cs

     文件       2874  2012-08-03 10:54  oledbwindows\oledbwindows\Properties\Resources.Designer.cs

     文件       5612  2012-08-03 10:54  oledbwindows\oledbwindows\Properties\Resources.resx

     文件       1097  2012-08-03 10:54  oledbwindows\oledbwindows\Properties\Settings.Designer.cs

............此处省略18个文件信息

评论

共有 条评论