Visual Studio 2017中的SQL数据库mysqlconnection错误 [英] Sql database mysqlconnection error in visual studio 2017

查看:218
本文介绍了Visual Studio 2017中的SQL数据库mysqlconnection错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SQL Server 2014使用SQL Server Manager 2017创建了数据库文件。

因此,当我尝试使用c#在Visual Studio 2017中连接我的数据库文件时出现此错误...



当我使用工具>从Visual Studio连接到数据库时,我也没有问题



(系统。 ArgumentException:'不支持选项。

参数名称:attachdbfilename')



<

I created Database file with SQL Server Manager 2017 using SQL Server 2014.
So when i try to connect my database file in Visual Studio 2017 with c# i get this error...

Also i don`t have problem when i Use Tools>Connect to Database from Visual Studio

(System.ArgumentException: 'Option not supported.
Parameter name: attachdbfilename')

<

InitializeComponent();
            string cs = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\PC\Desktop\Database\Database.mdf;Integrated Security=True;Connect Timeout=30";
            MySqlConnection con = new MySqlConnection(cs); //error here
            con.Open();

>



我尝试过:



................................. ............................................

>

What I have tried:

.............................................................................

推荐答案

您正在尝试使用MySQL连接(用于MySQL数据库)连接到MS SQL Server数据库。



你需要一个不同的连接。



C#SQL Server连接 [ ^ ]
You're trying to use a "MySQL" connection (for a MySQL database) to connect to an MS SQL Server database.

You need a "different" connection.

C# SQL Server Connection[^]


这篇关于Visual Studio 2017中的SQL数据库mysqlconnection错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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