如何检查是否数据库使用ODBC存在 [英] How to check if a database exists with ODBC

查看:454
本文介绍了如何检查是否数据库使用ODBC存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找在网上找了几天,现在并不能找到一个泛型方法只用ODBC和SQL来解决这个问题。

I have been searching the internet for a few days now and can't find a generic method to solve this with only ODBC and SQL.

有没有一种方法,如果数据库已经存在,只是使用的 ODBC 。它必须是标准的SQL,因为可以选择他所选择的DSN的用户(指他自己的SQL Server)。

Is there a way to see if a database already exist, only using ODBC. It has to be standard SQL because the user can chose a DSN of his choice (meaning his own SQL Server).

这意味着我不能检查主表中的服务器上,因为它们被命名为不同的SQL服务器上的不同。

This means I can't check the master table on the server because they are named different on different SQL servers.

感谢。

推荐答案

不知道这是不是太晚了,甚至足以为你便携式。

Don't know if this is too late, or even sufficiently "portable" for you.

我只需要处理与MS SQL,并且在使用选择的名字从一个master.dbo.sysdatabases中应用过去WHERE名称= @名称

I only have to deal with MS SQL, and in a past application used SELECT name FROM master.dbo.sysdatabases WHERE name = @name.

但是,在一个新的我使用ODBC的的SQLBrowseConnect (传递服务器名称和放大器;凭证),以获得在服务器的数据库列表。所以,我只是期待通过这些。我觉得原来的code表示来自 HTTP:// WWW。 codeproject.com / KB /数据库/ sqlsrvenumerator.aspx

But in a new one I am using the ODBC SQLBrowseConnect (passing in server name & credentials) to get a list of databases in the server. So I just look through those. I think the original code for that was from http://www.codeproject.com/KB/database/sqlsrvenumerator.aspx.

我没有ODBC专家,所以我不知道要在服务器(例如SQL浏览器服务)运行的需要或如何它的方法比较/实现。其实,我也不会介意别人的意见,以它是否有什么好的/更好!但它似乎是纯粹的ODBC的唯一!

I'm no ODBC expert, so I don't know what that requires to be running on the server (e.g. SQL Browser service) or how it compares in approach/is implemented. In fact, I wouldn't mind if anyone else comments as to whether it's any good/better! But it seems to be pure ODBC-only!

这篇关于如何检查是否数据库使用ODBC存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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