c#操作access数据库
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace AddressList
{
public partial class FrmAccessUse : Form
{
public FrmAccessUse()
{
InitializeComponent();
}
#region 调用access标准方法
// using System.Data.OleDb;
// using System.Data;
// 连接字符串:String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=product.mdb";
// 建立连接:OleDbConnection connection = new OleDbConnection(connectionString);
// 使用OleDbCommand类来执行Sql语句:
// OleDbCommand cmd = new OleDbCommand(sql, connection);
// connection.Open();
// cmd.ExecuteNonQuery();
#endregion
#region 连接字符串
//string strcon = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\程序书籍软件\c#程序代码\access数据库操作\addressList.mdb"; //绝对路径
string strcon = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Environment.CurrentDirectory+"\\addressList.mdb"; //相对路径
#endregion
#region 查询
private void tsbQuery_Click(object sender, EventArgs e)
{
query();
}
#endregion
#region 查询语句
private void query()
{
try
{
gridView1.Columns.Clear();
OleDbConnection connet1 = new OleDbConnection(strcon);
string sql = "select * from new1";
connet1.Open();
OleDbDataAdapter myadapter = new OleDbDataAdapter();
DataSet ds = new DataSet();
myadapter.SelectCommand = new OleDbCommand(sql, connet1);
myadapter.Fill(ds);
gridControl1.DataSource = ds.Tables[0];
connet1.Close();
相关文档:
HTML clipboard
Revealing the revolutionary fingerprint access clocking in/out system for
businesses. No more cards, no more paperwork, no more hassle! This digital
fingerprint access terminal and data logger registers finger prints for time
management plus also works as an authorized pe ......
问题:
有二个表
A表:
id Comment yuyan lanmuid
1 aaaa chinese 1
2 bbbb english 1
3 cccc chinese 2
4 ddddd english 2
B表:
id lanmu
1 公司简介
2 联系方式
3 经营范围
在删除B表的一行数据时会把A表关联ID的数据也删除,请问有什么好方法?我不想操作2次删除的语句.
解决方 ......
第一种方法:
<?php
class Access{
function getConn(){
$conn = @new COM("ADODB.Connection") or die ("ADO连接失败!");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath(__IMP ......
Take Equity Collection System as an example, Some other office collegues want to access it from home without VPN, The way to check is:
1. Check if it's limited in network, this needs to confirm with network people
2. If the step 1 passed, get the external IP address of the system, map ......
public class t3 : System.Web.UI.Page
{
private string str;//字符
&n ......