使用Windows上配置的DSN连接ODBC(无用户名和密码) [英] Connect ODBC (without username & password) using DSN configured on windows

查看:76
本文介绍了使用Windows上配置的DSN连接ODBC(无用户名和密码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用C#开发Windows窗体应用程序以与ODBC连接,选择表及其列,最后获取它们的数据.

I have an requirement to develop windows form application in C# to connect with ODBC, select tables and its columns and at last get their data.

我的确切需要是显示系统上可用的DSN列表,选择后显示其数据库,然后在其列之后显示内部的表列表.现在,在那之后,我需要将所有这些列与本地db列进行映射,并定期获取数据.

My exact need is to show list of DSN available on system and after selection that show its database and then show list of tables inside following with its column. Now after that I need to map all those columns with my local db column and periodically fetch data.

在进行编程时(请参见下面的代码),当我创建ODBC连接时会看到它询问我需要连接(用DSN配置)的数据库的用户名和密码,即使我已经在设置DSN时提供了这些凭据也是如此.控制面板.

When I come to programming (refer below code) I see while I create an ODBC connection it ask for Username and password of database I need to connect (configured with DSN) even if I already provide those credentials while setting up DSN in control panel.

OdbcConnection conn = new OdbcConnection("Dsn=MyDSN;Uid=***;Pwd=****;");
string query = "";
OdbcCommand cmd = new OdbcCommand(query, conn);
conn.Open();

我需要您的帮助,以确认这是正确的方法还是通过DSN直接连接db,而无需使用用户名和密码,因为我的客户在说我为什么应该在window应用程序中提供凭据,即使我已经提供了凭据DSN配置.

I need your help to confirm is it correct way or there is some other way also to connect db directly by DSN without using username and password as my customer is saying why I should provide credential in window application even if I already provided in DSN configuration.

推荐答案

我认为您在DSN配置向导中提供的凭据仅用于获取数据库列表.

I think that credentials, which you are providing in DSN Configuration wizard, are used only to fetch database list.

为什么即使我已经在DSN配置中提供窗口应用程序,也应该在窗口应用程序中提供凭据

why I should provide credential in window application even if I already provided in DSN configuration

不必在DSN配置中提供凭据.

It is not necessary to provide credentials in DSN configuration.

您还可能希望在服务器上创建一些服务(代理),可以将其配置为使用特定凭据.

Also you might want to create some service (proxy) on server, which could be configured to use specific credentials.

这篇关于使用Windows上配置的DSN连接ODBC(无用户名和密码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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