admin 管理员组文章数量: 1086019
2024年5月19日发(作者:navicat设置oracle表id自增)
using System;
using c;
using entModel;
using ;
using ;
using g;
using ;
using ;
using ;
using ;
namespace Location
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
= "Location System";
= "连接数据库";
= "查询";
= "退出";
= "添加";
= "删除";
= "修改";
= "ID:";
= "0";
}
private void button1_Click(object sender, EventArgs e)
{
string ConStr = "Provider=.4.0;data
source=";//创建OleDbConnection对象
OleDbConnection con = new OleDbConnection(ConStr);
();
if ( == )
{
("Access数据库的连接成功!", "Access数据库的连接");
}
else
{
("Access数据库的连接失败!", "Access数据库的连接");
}
();
}
private void button3_Click(object sender, EventArgs e) //退出
{
();
}
private void button2_Click(object sender, EventArgs e) //查询
模块
{
string ConStr = "Provider=.4.0;data
source=";//创建OleDbConnection对象
OleDbConnection con = new OleDbConnection(ConStr);
();
int i = 16(textBox1 .Text);
OleDbCommand cmd = new OleDbCommand("Select * From data where ID>=@id",
con);
("@id",i);
OleDbDataReader reader = eReader();
();
// = reader[0].ToString();
= reader[1].ToString();
= reader[2].ToString();
= reader[3].ToString();
= reader[4].ToString();
= reader[5].ToString();
= reader[6].ToString();
();
();
}
private void button4_Click(object sender, EventArgs e) //添加
{
string ConStr = "Provider=.4.0;data
source=";//创建OleDbConnection对象
OleDbConnection con = new OleDbConnection(ConStr);
();
for (int i = 0; i < 1000; i++)
{
string sql = "insert into data(ID)values(" + i + ")";
OleDbCommand cmd = new OleDbCommand(sql, con);
eNonQuery();
版权声明:本文标题:C#操作Access的查询、添加、删除、修改源程序 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1716053562a690946.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论