如何从visual studio C#连接到MS office数据库 [英] How to connenct from visual studio C# to MS office database

查看:89
本文介绍了如何从visual studio C#连接到MS office数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我喜欢从我的Visual Studio 2013 C#项目连接到MS Access 2013,但它不接受访问代码。 />


我的尝试:



Hello,

I like to make a connenction from my visual Studio 2013 C# project to MS Access 2013 but it don't accept the access code.

What I have tried:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;


namespace MysteriousYouTest
{
    public partial class Form1 : Form
    {
        String conn_string = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Flower\My Documents\Mysterious You.accdb;
Persist Security Info=False;











and

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;


namespace MysteriousYouTest
{
    public partial class Form1 : Form
    {
        String conn_string = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Flower\MyDocuments\MysteriousYou.accdb;
Persist Security Info=False;





和荷兰语因为windows版本是荷兰语





and in dutch because the windows version is dutch

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;


namespace MysteriousYouTest
{
    public partial class Form1 : Form
    {
        String conn_string = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Gebruikers\Flower\Mijn documenten\Mysterious You.accdb;
Persist Security Info=False;

推荐答案

检查:访问连接字符串 - ConnectionStrings.com [ ^ ]



正确的C#声明是:

Check this: Access connection strings - ConnectionStrings.com[^]

A proper C# statement is:
string sconn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\YourFolder\YourAccessFile.accdb;Persist Security Info=False;"





你看到了区别吗?



更多来自MSDN:

演练:连接到Access数据库中的数据(Windows窗体) [ ^ ]

连接到Access数据库 [ ^ ]

如何:使用SqlDataSource控件连接到Access数据库 [ ^ ]



Do you see the difference?

More at MSDN:
Walkthrough: Connecting to Data in an Access Database (Windows Forms)[^]
Connect to an Access Database[^]
How to: Connect to an Access Database Using the SqlDataSource Control[^]


这篇关于如何从visual studio C#连接到MS office数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆