C# DataGridView 存入 Access数据库问题
请问如何将DataGridview里的数据存入一个新的Access文件?
我的做法是:先用ADOX创建了一个新的数据库文件,然后将DataGridview的数据放入DataTable,再insert到刚建的mdb文件,但是在往里面创建表是老出错,为什么?我的代码如下:
DataTable dt = new DataTable();
for (int i = 0; i < displayDataGridView.Columns.Count; i++)
{
DataColumn dc = new DataColumn();
dc.ColumnName = displayDataGridView.Columns[i].HeaderText;
dt.Columns.Add(dc);
}
for (int i = 0; i < displayDataGridView.Rows.Count - 1; i++)
{
DataRow dr = dt.NewRow();
for (int j = 0; j < displayDataGridView.Columns.Count; j++)
{
dr[j] = displayDataGridView.Rows[i].Cells[j].Value;
}
dt.Rows.Add(dr);
}
string tablename="数据";
ADOX.CatalogClass cat = new CatalogClass();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";");
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+fileName);
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = "CREATE&nbs
相关问答:
//C 接口
extern "C"
{
TESSDLL_API int __cdecl GetTessText(const char *imagefile, char *text);
}
//我在C#中声明
//调用C DLL 中的函数
[DllImport("OCRapi.dll&quo ......
ACCESS数据库中有一个tablename表,设计如下
编号,书名,作者,出版时间,出版社,ISBN,目录,简介
其中除“编号”为自动编号外,其它都为“备注”
其中"编号"维一,在“ISBN”中有的为空值, ......
数据库连接提示如下报错,看的出来是页面与数据库连接的问题,现在我的是相对连接。
要怎么将其该成绝对连接呢?我的数据库文件路径在:
D:\web\db
还是要先谢谢大人们帮助小白菜我
Microsoft O ......
这两天学习《Delphi技术方案宝典》一书中第三章关于用户登录方案的例子,利用的是SQl Server数据库实现用户登录,编译运行都没问题,该实现的功能也都实现的很好,但是奇怪的是,反复运行一段时间后,有时在关闭整个 ......
在阿帕奇的web access log中,有一个是用户名选项,默认是域用户名。如果我用的是form 方式登陆,想把这个用户名写到access log中怎么实现?
楼上的, 现在的access log 是这样的
2009-07-04 02:16:37 110.110 ......