简体   繁体   English

无法将mysql服务器连接到Visual Studio

[英]Cant connect mysql server to visual studio

I've been trying to connect my MySQL server to Visual Studio 2017 on my C# Project. 我一直在尝试将MySQL服务器连接到C#项目上的Visual Studio 2017。 The MySQL Server I'm using off of Helios Hosting. 我在Helios Hosting上使用的MySQL Server。 Visual Studio Connects to the MySQL Server, But Always Pops Up W/ Error Messages. Visual Studio连接到MySQL服务器,但始终弹出W /错误消息。

Heres My MySQL Connection String Of The SQL 这是SQL的MySQL连接字符串

        `MySqlConnection sqlcon = new MySqlConnection(@"SERVER= The Remote ACESS HOST IP;DATABASE=jordan1g_LoginsDBs;UID=jordan1g;PASSWORD=*****;");`

It Worked Fine When I Used A Local SQL Server, Like SQL Express. 当我使用本地SQL Server(如SQL Express)时,它工作正常。 But the goal here it to have it run connected to the Remote SQL Server 但此处的目标是使其运行连接到远程SQL Server

Honestly, I've tried For hours and hours find fixes and try to fix it myself. 老实说,我已经尝试了好几个小时,不断寻找修补程序,然后尝试自己修复。 I'd really appreciate it if you guys could help me out. 如果你们能帮助我,我将非常感激。 I'm about to the point of ripping the hair out of my head, and punching my monitor. 我快要把头发从头上扯下来,然后猛击显示器。 Thanks! 谢谢! (BTW, I'm not really famillier w/ the community, if I'm doing anything wrong, pls let me know :-)) (顺便说一句,我并不是真正的社区成员,如果我做错了任何事情,请告诉我:-))

Try this and see what the console gives back. 试试看,看看控制台能给您些什么。

using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;

namespace DatbaseApplication
{
    public class Database
    {
        private MySqlConnection connection;

        public Database()
        {
            try
            {
                connection = new MySqlConnection("server=192.168.0.0;user id=databaseuser;password=databasepassword;persistsecurityinfo=True;database=databasename;allowuservariables=True");
            }
            catch(Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
     }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM