我用的是vs2005,数据库是access。
为什么导入数据库里的表时,又有一个数据库。就是我把数据库(a.mdb)放在bin下的debug下面,也就是工作目录。当dataGridView导入数据库表的内容时,在SystemA(这是我的项目的名称)这个文件夹下又有(a.mdb),这是怎么个原因?
我删除时debug下的数据库里的表有变化,但是SystemA下的没有变化,而且当再次运行的时候,debug下的数据库表里
的值和SystemA下的一样。我的代码是这样的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 CardSystem
{
public partial class ShowCard : Form
{
public ShowCard()
{
InitializeComponent();
} private void ShowCard_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“cardDataSet1.CardInfo”中。您可以根据需要移动或移除它。
this.cardInfoTableAdapter.Fill(this.cardDataSet1.CardInfo);
} private void button1_Click(object sender, EventArgs e)
{
if (this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString() == "")
{
MessageBox.Show("请选择要删除的行!");
}
else
{
if (MessageBox.Show("确认删除?", "提示", MessageBoxButtons.YesNo) ==DialogResult.Yes)
{
for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++)
{ string strRow = this.dataGridView1.SelectedRows[i].Cells[0].Value.ToString();
string strRowDel = "delete from CardInfo where ID=" + strRow + "";
OleDbCommand cmd = new OleDbCommand(strRowDel, DBHelper.oleCon);
DBHelper.oleCon.Open();
int count = cmd.ExecuteNonQuery();
DBHelper.oleCon.Close();
}
dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
}
}
}
}
}
为什么导入数据库里的表时,又有一个数据库。就是我把数据库(a.mdb)放在bin下的debug下面,也就是工作目录。当dataGridView导入数据库表的内容时,在SystemA(这是我的项目的名称)这个文件夹下又有(a.mdb),这是怎么个原因?
我删除时debug下的数据库里的表有变化,但是SystemA下的没有变化,而且当再次运行的时候,debug下的数据库表里
的值和SystemA下的一样。我的代码是这样的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 CardSystem
{
public partial class ShowCard : Form
{
public ShowCard()
{
InitializeComponent();
} private void ShowCard_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“cardDataSet1.CardInfo”中。您可以根据需要移动或移除它。
this.cardInfoTableAdapter.Fill(this.cardDataSet1.CardInfo);
} private void button1_Click(object sender, EventArgs e)
{
if (this.dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString() == "")
{
MessageBox.Show("请选择要删除的行!");
}
else
{
if (MessageBox.Show("确认删除?", "提示", MessageBoxButtons.YesNo) ==DialogResult.Yes)
{
for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++)
{ string strRow = this.dataGridView1.SelectedRows[i].Cells[0].Value.ToString();
string strRowDel = "delete from CardInfo where ID=" + strRow + "";
OleDbCommand cmd = new OleDbCommand(strRowDel, DBHelper.oleCon);
DBHelper.oleCon.Open();
int count = cmd.ExecuteNonQuery();
DBHelper.oleCon.Close();
}
dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
}
}
}
}
}
解决方案 »
- 重绘用户控件,不能调用Paint事件
- 高分求怎么显示
- C#记事本 ,保存。
- 将Grideview中的数据批量添加到数据库
- Helps the Chinese WEB programmer{支持---请回复您收集的网址或感言} 程序行动---没有分数,有的只是一颗互助的心,希望大家支持.........
- 另开了一个线程执行某个函数,怎样知道这个线程什么时候执行完成?
- 关于存储过程调用
- 如何替换同名文件?
- 高手都去哪里了?帮忙看看.
- 高手请进,实现两个树控件节点之间的画线,在线等待,急!!!谢谢了
- 在winform中写事务,我只想让一张表只添加一条记录,另一张表根据前一张表里面的一个字段的个数进行插入
- 合并格
就是说当你是编译运行的时候就会出现这种问题,
但是如果你直接运行bin\debug下面的执行文件就应该没问题了