资源简介
利用C#远程存取Access数据库
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace Remoteobject
{
public class CRemoteAccess : MarshalByRefobject
{
public static string m_ConnString;
private string m_sqlQuery;
private OleDbConnection m_connection;
private OleDbCommand m_command;
private OleDbDataAdapter m_adapter;
private OleDbCommandBuilder m_builder;
private DataSet m_ds;
private DataTable m_userTable;
public CRemoteAccess()
{
}
public void SetRemoteAccessConnString(string Connstr)
{
m_ConnString = Connstr;
}
public string GetRemoteAccessConnString()
{
return m_ConnString;
}
private void SetDataobjects()
{
m_connection = new OleDbConnection(m_ConnString);
m_command = new OleDbCommand(m_sqlQuery m_connection);
m_adapter = new OleDbDataAdapter(m_command);
m_builder = new OleDbCommandBuilder(m_adapter);
m_ds = new DataSet(“MainDataSet“);
}
public bool TestConnectionIsOK(string connstr)
{
OleDbConnection testconn = null;
try
{
testconn = new OleDbConnection(connstr);
testconn.Open();
return true;
}
catch
{
return false;
}
finally
{
testconn.Close();
}
}
private void LoadData(string SqlStr string TableName)
{
try
{
if (m_userTable != null)
{
m_userTable.Clear();
}
m_sqlQuery = SqlStr;// “select * from Test“;
SetDataobjects();
m_connection.Open();
m_adapter.Fill(m_ds TableName);
m_userTable = m_ds.Tables[TableName];
}
catch //(Exception ex)
{
}
finally
{
m_connection.Close();
}
}
public void SaveData(DataTable ClientDataTable)
{
try
{
m_connection.Open();
m_adapter.Update(ClientDataTable);
}
catch //(Exception ex)
{
}
finally
{
m_connection.Close();
}
}
public DataTable GetUserTable(string SqlStr string TableName)
{
LoadData(SqlStr TableName);
return m_userTable;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 143360 2007-06-21 12:13 TestRemoteAccess\Demo\db.mdb
文件 16384 2007-07-31 20:09 TestRemoteAccess\Demo\Remoteob
文件 24576 2007-07-31 20:38 TestRemoteAccess\Demo\TestClient.exe
文件 24576 2007-07-31 20:38 TestRemoteAccess\Demo\TestServer.exe
文件 2873 2007-07-29 20:17 TestRemoteAccess\Remoteob
文件 16384 2007-07-31 20:32 TestRemoteAccess\Remoteob
文件 16384 2007-07-31 20:09 TestRemoteAccess\Remoteob
文件 15872 2007-07-31 20:09 TestRemoteAccess\Remoteob
文件 16384 2007-07-28 17:22 TestRemoteAccess\Remoteob
文件 13824 2007-07-28 17:22 TestRemoteAccess\Remoteob
文件 372 2007-07-31 20:38 TestRemoteAccess\Remoteob
文件 1374 2007-07-28 17:05 TestRemoteAccess\Remoteob
文件 1967 2007-07-28 16:51 TestRemoteAccess\Remoteob
文件 2232 2007-07-31 20:38 TestRemoteAccess\TestClient\frmTestClient.cs
文件 7683 2007-07-31 20:32 TestRemoteAccess\TestClient\frmTestClient.Designer.cs
文件 7742 2007-07-31 20:32 TestRemoteAccess\TestClient\frmTestClient.resx
文件 908 2007-07-31 20:38 TestRemoteAccess\TestClient\obj\Debug\TestClient.csproj.GenerateResource.Cache
文件 24576 2007-07-31 20:38 TestRemoteAccess\TestClient\obj\Debug\TestClient.exe
文件 180 2007-07-31 20:38 TestRemoteAccess\TestClient\obj\Debug\TestClient.frmTestClient.resources
文件 32256 2007-07-31 20:38 TestRemoteAccess\TestClient\obj\Debug\TestClient.pdb
文件 180 2007-07-31 20:09 TestRemoteAccess\TestClient\obj\Debug\TestClient.Properties.Resources.resources
文件 850 2007-07-28 17:22 TestRemoteAccess\TestClient\obj\Release\TestClient.csproj.GenerateResource.Cache
文件 20480 2007-07-28 17:22 TestRemoteAccess\TestClient\obj\Release\TestClient.exe
文件 180 2007-07-28 17:22 TestRemoteAccess\TestClient\obj\Release\TestClient.frmTestClient.resources
文件 19968 2007-07-28 17:22 TestRemoteAccess\TestClient\obj\Release\TestClient.pdb
文件 180 2007-07-28 17:22 TestRemoteAccess\TestClient\obj\Release\TestClient.Properties.Resources.resources
文件 668 2007-07-31 20:38 TestRemoteAccess\TestClient\obj\TestClient.csproj.FileList.txt
文件 477 2007-07-28 17:12 TestRemoteAccess\TestClient\Program.cs
文件 1225 2007-07-28 17:05 TestRemoteAccess\TestClient\Properties\AssemblyInfo.cs
文件 2875 2007-07-28 16:48 TestRemoteAccess\TestClient\Properties\Resources.Designer.cs
............此处省略113个文件信息
相关资源
- C#源码电脑信息系统
- PDF合并拆分 C#源码
- 国密SM2_SM3加密解密,加签验签操作
- C#网络监控软件代码
- 字符串加密与解密C#源码
- C#开发大全(基础卷)源码+C#开发大全
- 开发框架 C#源码
- 局域网聊天软件C#源码
- MODBUS TCP C# 源码 -- 测试过信捷PLC
- 个人日记管理系统 C#源码 三层 SQL数据
- 远程监控数据采集GPRSC#源码
- 扫雷游戏_C# 源码
- 植物大战僵尸C#源码mvc
- 布尔莎七参数求解__C#源码
- 西门子PLC与上位机C#源码Snap7.rar
- YU_字形轮廓提取显示C#源码.rar
- C#手写识别源码
- 绘制矢量图C#源码
- 24路舵机控制板C#源码
- 用于验证码图片识别的类C#源码
- asp.net实现文件夹上传、修改、删除,
- 栅格数据压缩—块状编码C#源码
- xmodem通讯协议c#源码全网独一份绝对值
- A*寻路算法实现C#源码——A Star find
- C#源码-影院售票系统
-
xm
l文件操作 C#源码 - 网络文件传送 c#源码
- 仿QQ的C#源码、仿QQ的C#源码
- 国密算法SM2、SM3、SM4的C#源码
- 电话卡销售管理系统(c#源码)
评论
共有 条评论