无法连接到远程SQL服务器在C# [英] Can't connect to remote SQL server in C#

查看:239
本文介绍了无法连接到远程SQL服务器在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个freesqldatabase.com数据库,并在编写C#脚本连接到它的过程中,我似乎无法得到它的成功连接。我认为这个问题是在连接字符串中,但我不知道是什么问题。我一直在试图从文档获得建议,但我一直没能解决它。我的连接方法如下:

I created a database on freesqldatabase.com and was in the process of writing a C# script to connect to it and I cannot seem to get it to connect successfully. I think the issue is in the connection string, but I'm not sure what the problem is. I've been trying to get advice from documentation, but I haven't been able to fix it. My connection method is below:

请注意:connAddr = sql3.freesqldatabase.com

Note: connAddr = sql3.freesqldatabase.com

请注意:端口= 3306

Note: port = 3306

    public static void Connect(string connAddr, int port)
    {
        CloseConnection();

        Conn = new SqlConnection();

        Conn.ConnectionString =
            "Data Source=" + connAddr + "," + port + ";" +
            "Initial Catalog=sql332572;" +
            "user id=sql332572;" +
            "pwd=xxxxxxxx";
        Conn.Open();
    }



我收到以下错误。谷歌搜索似乎并没有给我这个特殊的错误的任何信息:

I am getting the below error. Searching Google didn't seem to give me any information on this particular error:

Exception: Unknown packet type 91
Mono.Data.Tds.Protocol.TdsComm.GetPhysicalPacketHeader ()
Mono.Data.Tds.Protocol.TdsComm.GetPhysicalPacket ()
Mono.Data.Tds.Protocol.TdsComm.GetByte ()

你们能看到什么毛病我的连接字符串?任何帮助是极大的赞赏。谢谢!

Can you guys see anything wrong with my connection string? Any help is greatly appreciated. Thanks!

推荐答案

据的 http://www.freesqldatabase.com/mssql/

他们即将推出的MS SQL Server连接,也就是说,它们不提供它现在。什么是你想连接到?如果它是MySQL比的SqlConnection是行不通的。

they will launch MS SQL Server connection soon, i.e. they don't provide it now. What are you trying to connect to? If it is MySql than Sqlconnection would not work.

这篇关于无法连接到远程SQL服务器在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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