逃生;(分号)在app.config文件ODBC连接字符串 [英] Escape ;(semicolon) in odbc connection string in app.config file

查看:474
本文介绍了逃生;(分号)在app.config文件ODBC连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了某些字段的Windows窗体。我试图通过ODBC DSN连接Oracle数据库进行交互。

I have created a windows form with certain fields. I am trying to interact with oracle database through ODBC DSN connections.

我有一个问题,下面的连接字符串中的app.config中。

I have an issue in the below connection string in app.config .

在连接字符串密码包含分号(ABC这里; 45)。我得到一个错误:

In the connection string password contains semicolon(here abc;45). I am getting an error:

初始化字符串的格式不符合规范开始于索引35

当我尝试使用

OdbcConnection连接来访问该连接字符串=新OdbcConnection(connection_string);

在C#代码

下面是我的连接。字符串

Below is my connection string.

<add name="ConnectionString_T1" connectionString="DSN=CLA_T5;Uid=abc;Pwd=abc;45" providerName="System.Data.Odbc" />

 OdbcConnection connection = new OdbcConnection(connection_string);



PS:我尝试用双引号把这个密码/单引号/" 。但是没有用。仍然面临这个错误。我试图把像"所有的转义序列;,双引号,单引号,/等。

PS: I tried putting this password in double quotes/single quote/" . But no use. Still facing this error. I have tried putting all the escape sequences like ",double quote, single quote,/" etc..

推荐答案

显然, ODBC特别是当它涉及到转义连接字符串值以分号,等号等。根据的这个,你应该在大括号中的特殊字符包围值{}

Apparently, ODBC is special when it comes to escaping connection string values with semicolons, equal signs, etc. According to this, you should enclose values with special characters in curly braces {}

connectionString="DSN=CLA_T5;Uid=abc;Pwd={abc;45}"

这篇关于逃生;(分号)在app.config文件ODBC连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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