mysql的连接字符串

编程入门 行业动态 更新时间:2024-10-26 17:31:43
本文介绍了mysql的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我认为这是一个相当简单的问题,但是我找不到找到使它起作用的方法. 在我的项目中,配置文件上有一个连接字符串,它像这样;

Hello guys, I think this is a fairly easy question but i couldnt find a way to make it work. On my project I have a connection string on the config file it goes like this;

<appSettings> <add key ="connectionstring" value="server=204.12.119.53;User Id=devgad_user; Password=;hamT)gTpp^A; database=devgad_testing;Allow Zero Datetime=true;"/> </appSettings>

在我的代码行中;

In the line of my code;

connection = new MySqlConnection(connectionstring);

我在这里有一个错误; 初始化字符串的格式不符合从索引114开始的规范." 我尝试从 www.connectionstrings [ ^ ] 我认为我得到的第二个错误更有用.您有什么想法可以分享吗? 因此,只是尝试是否可以建立连接,所以我创建了另一个项目.我用了这条线;

I have an error here as; "Format of the initialization string does not conform to specification starting at index 114." I tried the connection strings formats for mysql from www.connectionstrings[^] I think the second error I got is more helpful. any thoughts that you may share? So just to try if I can establish a connection I created another project. I used this line;

MySqlConnection conn = new MySqlConnection("server=xxx.xx.xxx.xx;User Id=devgad_user; Password=;hamT)gTpp^A; database=devgad_testing;Allow Zero Datetime=true;");

在这里,我收到了错误消息不支持关键字. 参数名称:hamt)gtpp ^ a;数据库"

Here I got an error as "Keyword not supported. Parameter name: hamt)gtpp^a; database"

推荐答案

好,您的密码以分号开头,分号是系统使用的参数分隔符.因此,它将连接字符串解释为blah=blah; password=""; hamT)gTpp^A并且它认为最后一个(您的密码)是关键字. 我不确定是否可以将其用引号引起来,但这总是会给您带来麻烦,那么为什么不将密码更改为不以控制"字符开头的密码呢? Well, your password starts with a semi-colon which is the parameter separator used by the system. So it is interpreting your connection string as blah=blah; password=""; hamT)gTpp^A and it thinks the last one (your password) is a keyword. I am not sure if you can enclose it in quotes or not but it is always going to give you problems, so why not change your password to something that doesn''t begin with a ''control'' character?

您的密码字符串中包含分号.这是连接字符串的关键字/值定界符.使连接对象认为您没有提供密码,并且声明了不存在的关键字. There is a semi-colon in your password string. This is the key word/value delimiter for connection strings. Makes the connection object think you did not supply a password and are declaring a key word that does not exist.

更多推荐

mysql的连接字符串

本文发布于:2023-10-24 14:59:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524247.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   mysql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!